Class: Vec4

og/math/Vec4.Vec4

Class represents a 4d vector.

new module:og/math/Vec4.Vec4(x, y, z, w)

Name Type Description
x number optional First value.
y number optional Second value.
z number optional Third value.
w number optional Fourth value.

Members

wnumber

xnumber

ynumber

znumber

static,constantmodule:og/math/Vec4.Vec4.identityVec4

Identity vector [0,0,0,1].

Methods

addA(v){Vec4}

Adds vector to the current.
Name Type Description
v Vec4
Returns:
Type Description
Vec4

affinity(){Vec4}

Makes vector affinity. Thereby fourh component becomes to 1.0.
Returns:
Type Description
Vec4

clone(){Vec4}

Returns clone vector.
Returns:
Type Description
Vec4

copy(v){Vec4}

Copy input vector's values.
Name Type Description
v Vec4 Vector to copy.
Returns:
Type Description
Vec4

dot(v){number}

Gets vectors dot production.
Name Type Description
v math.Vec4 Another vector.
Returns:
Type Description
number - Dot product.

equal(p){boolean}

Compares with vector. Returns true if it equals another.
Name Type Description
p Vec4 Vector to compare.
Returns:
Type Description
boolean

getFrac(){Vec4}

The vector fract function returns the vector of fractional parts of each value, i.e. x minus floor(x).
Returns:
Type Description
Vec4

getStep(){Vec4}

Vector's edge function that returns vector where each component is 0.0 if it's smaller then edge and otherwise 1.0.
Returns:
Type Description
Vec4

isZero(){boolean}

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

scale(scale){Vec4}

Scale current vector.
Name Type Description
scale number Scale value.
Returns:
Type Description
Vec4

scaleTo(scale){Vec3}

Scale current vector to another instance.
Name Type Description
scale number Scale value.
Returns:
Type Description
Vec3

set(x, y, z, w){Vec4}

Sets vector's values.
Name Type Description
x number Value X.
y number Value Y.
z number Value Z.
w number Value W.
Returns:
Type Description
Vec4

subA(v){Vec4}

Subtract vector from the current.
Name Type Description
v Vec4 Subtract vector.
Returns:
Type Description
Vec4

toArray(){Array.<number>}

Converts vector to a number array.
Returns:
Type Description
Array.<number> - (exactly 4 entries)

toVec(){Array.<number>}

Converts vector to a number array.
Deprecated
  • Yes
Returns:
Type Description
Array.<number> - (exactly 4 entries)

toVec3(){Vec3}

Converts to 3d vector, without fourth value.
Returns:
Type Description
Vec3

staticmodule:og/math/Vec4.Vec4.fromVec(arr){Vec4}

Creates 4d vector from array.
Name Type Description
arr Array.<number> (exactly 4 entries)
Returns:
Type Description
Vec4