Class: Vector2

og.math.Vector2

new og.math.Vector2(x, y)

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

Members

xnumber

ynumber

static,constantog.math.Vector2.DOWN

static,constantog.math.Vector2.LEFT

static,constantog.math.Vector2.RIGHT

static,constantog.math.Vector2.UP

static,constantog.math.Vector2.ZERO

Methods

Summarize two vectors.
Name Type Description
v og.math.Vector2
Returns:
Type Description
og.math.Vector2
Adds vector to the current.
Name Type Description
v og.math.Vector2
Returns:
Type Description
og.math.Vector2

angle(a){number}

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

distance(p){number}

Gets distance to point.
Name Type Description
p og.math.Vector2 Distant point.
Returns:
Type Description
number
Divide current vector's components to another. Results stores in the current vector object.
Name Type Description
vec og.math.Vector2
Returns:
Type Description
og.math.Vector2

dot(v){number}

Gets vectors dot production.
Name Type Description
v og.math.Vector2 Another vector.
Returns:
Type Description
number

dotArr(arr){number}

Gets vectors dot production.
Name Type Description
arr Array.<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.Vector2 Vector to compare.
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.Vector2 End vector.
l number Interpolate value.
Returns:
Type Description
og.math.Vector2
Multiply current vector object to another and returns new vector instance.
Name Type Description
vec og.math.Vector2 Multiply vector.
Returns:
Type Description
og.math.Vector2
Multiply current vector object to another and store result in the current instance.
Name Type Description
vec og.math.Vector2 Multiply vector.
Returns:
Type Description
og.math.Vector2
Negate current vector.
Returns:
Type Description
og.math.Vector2
Negate current vector to another instance.
Returns:
Type Description
og.math.Vector2
Returns normalized vector.
Returns:
Type Description
og.math.Vector2
Normalize current vector.
Returns:
Type Description
og.math.Vector2

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

Gets projected point coordinates of the current vector on the ray.
Name Type Description
pos og.math.Vector2 Ray position.
direction og.math.Vector2 Ray direction.
Returns:
Type Description
og.math.Vector2
Scale current vector.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.math.Vector2
Scale current vector to another instance.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.math.Vector2
Sets vector's values.
Name Type Description
x number Value X.
y number Value Y.
Returns:
Type Description
og.math.Vector2
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.Vector2 -
t number The parameter t is clamped to the range [0, 1].
Returns:
Type Description
og.math.Vector2
Subtract vector from the current.
Name Type Description
v og.math.Vector2 Subtract vector.
Returns:
Type Description
og.math.Vector2
Subtract vector from the current where results saved on the current instance.
Name Type Description
v og.math.Vector2 Subtract vector.
Returns:
Type Description
og.math.Vector2

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

Converts vector to a number array.
Returns:
Type Description
Array.<number, number>
Converts to 3d vector, third value is 0.0.
Returns:
Type Description
og.math.Vector3

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

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

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

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

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

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

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

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

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

Makes vectors normalized and orthogonal to each other.
Name Type Description
normal og.math.Vector2 Normal vector.
tangent og.math.Vector2 Tangent vector.
Returns:
Type Description
og.math.Vector2

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

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

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

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

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

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