Class: Vector3

og.math.Vector3

new og.math.Vector3(x, y, z)

Class represents a 3d vector.
Name Type Description
x number optional First value.
y number optional Second value.
z number optional Third value.

Members

xnumber

ynumber

znumber

static,constantog.math.Vector3.BACKWARD

static,constantog.math.Vector3.DOWN

static,constantog.math.Vector3.FORWARD

static,constantog.math.Vector3.LEFT

static,constantog.math.Vector3.RIGHT

static,constantog.math.Vector3.UP

static,constantog.math.Vector3.ZERO

Methods

Gets two vectors summarization.
Name Type Description
point3 og.math.Vector3 Vector to add.
Returns:
Type Description
og.math.Vector3 Returns a sum vector.
Adds vector to the current.
Name Type Description
point3 og.math.Vector3
Returns:
Type Description
og.math.Vector3

angle(a){number}

Gets angle between two vectors.
Name Type Description
a og.math.Vector3 Another vector.
Returns:
Type Description
number
Sets vector to zero.
Returns:
Type Description
og.math.Vector3
Returns clone vector.
Returns:
Type Description
og.math.Vector3
Copy input vector's values.
Name Type Description
point3 og.math.Vector3 Vector to copy.
Returns:
Type Description
og.math.Vector3
Gets vectors cross production.
Name Type Description
point3 og.math.Vector3 Another vector.
Returns:
Type Description
og.math.Vector3

distance(point3){number}

Gets distance to point.
Name Type Description
point3 og.math.Vector3 Distant point.
Returns:
Type Description
number
Divide current vector's components to another and returns new vector instance.
Name Type Description
vec og.math.Vector3
Returns:
Type Description
og.math.Vector3
Divide current vector's components to another. Results stores in the current vector object.
Name Type Description
vec og.math.Vector3
Returns:
Type Description
og.math.Vector3

dot(point3){number}

Gets vectors dot production.
Name Type Description
point3 og.math.Vector3 Another vector.
Returns:
Type Description
number

dotArr(arr){number}

Gets vectors dot production.
Name Type Description
arr Array.<number, number, number> Array vector.
Returns:
Type Description
number

equal(p){boolean}

Compares with vector. Returns true if it equals another.
Name Type Description
p og.math.Vector3 Vector to compare.
Returns:
Type Description
boolean
Converts vector's values to a quaternion object.
Returns:
Type Description
og.math.Quaternion

isZero(){boolean}

Returns true if vector's values are zero.
Returns:
Type Description
boolean

length(){number}

Gets vector's length.
Returns:
Type Description
number

length2(){number}

Returns squared vector's length.
Returns:
Type Description
number
Returns two vectors linear interpolation.
Name Type Description
v2 og.math.Vector3 End vector.
l number Interpolate value.
Returns:
Type Description
og.math.Vector3
Multiply current vector object to another and returns new vector instance.
Name Type Description
vec og.math.Vector3 Multiply vector.
Returns:
Type Description
og.math.Vector3
Multiply current vector object to another and store result in the current instance.
Name Type Description
vec og.math.Vector3 Multiply vector.
Returns:
Type Description
og.math.Vector3
Negate current vector.
Returns:
Type Description
og.math.Vector3
Negate current vector to another instance.
Returns:
Type Description
og.math.Vector3
Returns normalized vector.
Returns:
Type Description
og.math.Vector3
Normalize current vector.
Returns:
Type Description
og.math.Vector3

projToRay(pos, direction){og.math.Vector3}

Gets projected point coordinates of the current vector on the ray.
Name Type Description
pos og.math.Vector3 Ray position.
direction og.math.Vector3 Ray direction.
Returns:
Type Description
og.math.Vector3
Scale current vector.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.math.Vector3
Scale current vector to another instance.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.math.Vector3
Sets vector's values.
Name Type Description
x number Value X.
y number Value Y.
z number Value Z.
Returns:
Type Description
og.math.Vector3
Spherically interpolates between two vectors. Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated by the angle and its magnitude is interpolated between the magnitudes of from and to.
Name Type Description
v2 og.math.Vector3 -
t number The parameter t is clamped to the range [0, 1].
Returns:
Type Description
og.math.Vector3
Returns vector interpolation by v(t) = v1 * t + v2 * (1 - t)
Name Type Description
v2 og.math.Vector3 End vector.
t number Interpolate value.
Returns:
Type Description
og.math.Vector3
Gets vector subtraction.
Name Type Description
point3 og.math.Vector3 Subtract vector.
Returns:
Type Description
og.math.Vector3 Returns new instance of a subtraction
Subtract vector from the current.
Name Type Description
point3 og.math.Vector3 Subtract vector.
Returns:
Type Description
og.math.Vector3

toString(){string}

Converts vector to text string.
Returns:
Type Description
string

toVec(){Array.<number, number, number>}

Converts vector to a number array.
Returns:
Type Description
Array.<number, number, number>
Converts to 4d vector, Fourth value is 1.0.
Returns:
Type Description
og.math.Vector4

staticog.math.Vector3.add(a, b){og.math.Vector3}

Returns summary vector.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3 - Summary vector.

staticog.math.Vector3.angle(a, b){number}

Gets angle between two vectors.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
number

staticog.math.Vector3.div(a, b){og.math.Vector3}

Returns vector components division product one to another.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.fromVec(arr){og.math.Vector3}

Creates 3d vector from array.
Name Type Description
arr Array.<number, number, number>
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.lerp(v1, v2, l){og.math.Vector3}

Returns two vectors linear interpolation.
Name Type Description
v1 og.math.Vector3 Start vector.
v2 og.math.Vector3 End vector.
l number Interpolate value.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.mul(a, b){og.math.Vector3}

Returns two vectors production.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.noncollinear(a, b){og.math.Vector3}

Returns true if two vectors are non collinear.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.orthoNormalize(normal, tangent){og.math.Vector3}

Makes vectors normalized and orthogonal to each other. Normalizes normal. Normalizes tangent and makes sure it is orthogonal to normal (that is, angle between them is 90 degrees).
Name Type Description
normal og.math.Vector3 Normal vector.
tangent og.math.Vector3 Tangent vector.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.proj_b_to_a(b, a){og.math.Vector3}

Get projection of the first vector to the second.
Name Type Description
b og.math.Vector3 First vector.
a og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.proj_b_to_plane(b, n){og.math.Vector3}

Get projection of the vector to plane where n - normal to the plane.
Name Type Description
b og.math.Vector3 Vector.
n og.math.Vector3 Plane normal.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.scale(a, scale){og.math.Vector3}

Returns scaled vector.
Name Type Description
a og.math.Vector3 Input vector.
scale number Scale value.
Returns:
Type Description
og.math.Vector3

staticog.math.Vector3.sub(a, b){og.math.Vector3}

Returns two vectors subtraction.
Name Type Description
a og.math.Vector3 First vector.
b og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Vector3 - Vectors subtraction.