Methods
add(out, a, b) → {mat2d}
Adds two mat2d's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the first operand |
b |
mat2d | the second operand |
Returns:
out
- Type
- mat2d
add(out, a, b) → {mat2}
Adds two mat2's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the first operand |
b |
mat2 | the second operand |
Returns:
out
- Type
- mat2
add(out, a, b) → {vec3}
Adds two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
add(out, a, b) → {vec4}
Adds two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
add(out, a, b) → {mat4}
Adds two mat4's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the first operand |
b |
mat4 | the second operand |
Returns:
out
- Type
- mat4
add(out, a, b) → {vec2}
Adds two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
add(out, a, b) → {mat3}
Adds two mat3's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the first operand |
b |
mat3 | the second operand |
Returns:
out
- Type
- mat3
adjoint(out, a) → {mat4}
Calculates the adjugate of a mat4
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the source matrix |
Returns:
out
- Type
- mat4
adjoint(out, a) → {mat2}
Calculates the adjugate of a mat2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the source matrix |
Returns:
out
- Type
- mat2
adjoint(out, a) → {mat3}
Calculates the adjugate of a mat3
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the source matrix |
Returns:
out
- Type
- mat3
angle(a, b) → {Number}
Get the angle between two 3D vectors
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | The first operand |
b |
vec3 | The second operand |
Returns:
The angle in radians
- Type
- Number
bezier(out, a, b, c, d, t) → {vec3}
Performs a bezier interpolation with two control points
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
c |
vec3 | the third operand |
d |
vec3 | the fourth operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- vec3
calculateW(out, a) → {quat}
Calculates the W component of a quat from the X, Y, and Z components.
Assumes that quaternion is 1 unit in length.
Any existing W component will be ignored.
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
a |
quat | quat to calculate W component of |
Returns:
out
- Type
- quat
ceil(out, a) → {vec2}
Math.ceil the components of a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to ceil |
Returns:
out
- Type
- vec2
ceil(out, a) → {vec3}
Math.ceil the components of a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to ceil |
Returns:
out
- Type
- vec3
ceil(out, a) → {vec4}
Math.ceil the components of a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to ceil |
Returns:
out
- Type
- vec4
clone(a) → {vec4}
Creates a new vec4 initialized with values from an existing vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | vector to clone |
Returns:
a new 4D vector
- Type
- vec4
clone(a) → {vec2}
Creates a new vec2 initialized with values from an existing vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | vector to clone |
Returns:
a new 2D vector
- Type
- vec2
clone(a) → {mat4}
Creates a new mat4 initialized with values from an existing matrix
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | matrix to clone |
Returns:
a new 4x4 matrix
- Type
- mat4
clone(a) → {mat2d}
Creates a new mat2d initialized with values from an existing matrix
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | matrix to clone |
Returns:
a new 2x3 matrix
- Type
- mat2d
clone(a) → {mat2}
Creates a new mat2 initialized with values from an existing matrix
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | matrix to clone |
Returns:
a new 2x2 matrix
- Type
- mat2
clone(a) → {vec3}
Creates a new vec3 initialized with values from an existing vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | vector to clone |
Returns:
a new 3D vector
- Type
- vec3
clone(a) → {mat3}
Creates a new mat3 initialized with values from an existing matrix
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | matrix to clone |
Returns:
a new 3x3 matrix
- Type
- mat3
conjugate(out, a) → {quat}
Calculates the conjugate of a quat
If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
a |
quat | quat to calculate conjugate of |
Returns:
out
- Type
- quat
copy(out, a) → {mat2d}
Copy the values from one mat2d to another
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the source matrix |
Returns:
out
- Type
- mat2d
copy(out, a) → {mat3}
Copy the values from one mat3 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the source matrix |
Returns:
out
- Type
- mat3
copy(out, a) → {vec3}
Copy the values from one vec3 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the source vector |
Returns:
out
- Type
- vec3
copy(out, a) → {vec2}
Copy the values from one vec2 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the source vector |
Returns:
out
- Type
- vec2
copy(out, a) → {mat4}
Copy the values from one mat4 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the source matrix |
Returns:
out
- Type
- mat4
copy(out, a) → {mat2}
Copy the values from one mat2 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the source matrix |
Returns:
out
- Type
- mat2
copy(out, a) → {vec4}
Copy the values from one vec4 to another
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the source vector |
Returns:
out
- Type
- vec4
create() → {vec4}
Creates a new, empty vec4
Returns:
a new 4D vector
- Type
- vec4
create() → {mat4}
Creates a new identity mat4
Returns:
a new 4x4 matrix
- Type
- mat4
create() → {vec3}
Creates a new, empty vec3
Returns:
a new 3D vector
- Type
- vec3
create() → {mat2d}
Creates a new identity mat2d
Returns:
a new 2x3 matrix
- Type
- mat2d
create() → {vec2}
Creates a new, empty vec2
Returns:
a new 2D vector
- Type
- vec2
create() → {mat3}
Creates a new identity mat3
Returns:
a new 3x3 matrix
- Type
- mat3
create() → {quat}
Creates a new identity quat
Returns:
a new quaternion
- Type
- quat
create() → {mat2}
Creates a new identity mat2
Returns:
a new 2x2 matrix
- Type
- mat2
cross(out, a, b) → {vec3}
Computes the cross product of two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
cross(out, a, b) → {vec3}
Computes the cross product of two vec2's
Note that the cross product must by definition produce a 3D vector
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec3
determinant(a) → {Number}
Calculates the determinant of a mat3
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | the source matrix |
Returns:
determinant of a
- Type
- Number
determinant(a) → {Number}
Calculates the determinant of a mat2d
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | the source matrix |
Returns:
determinant of a
- Type
- Number
determinant(a) → {Number}
Calculates the determinant of a mat2
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | the source matrix |
Returns:
determinant of a
- Type
- Number
determinant(a) → {Number}
Calculates the determinant of a mat4
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | the source matrix |
Returns:
determinant of a
- Type
- Number
distance(a, b) → {Number}
Calculates the euclidian distance between two vec4's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
distance between a and b
- Type
- Number
distance(a, b) → {Number}
Calculates the euclidian distance between two vec3's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
distance between a and b
- Type
- Number
distance(a, b) → {Number}
Calculates the euclidian distance between two vec2's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
distance between a and b
- Type
- Number
divide(out, a, b) → {vec2}
Divides two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
divide(out, a, b) → {vec3}
Divides two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
divide(out, a, b) → {vec4}
Divides two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
dot(a, b) → {Number}
Calculates the dot product of two vec2's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
dot product of a and b
- Type
- Number
dot(a, b) → {Number}
Calculates the dot product of two vec4's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
dot product of a and b
- Type
- Number
dot(a, b) → {Number}
Calculates the dot product of two vec3's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
dot product of a and b
- Type
- Number
equals(a, b) → {Boolean}
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | The first vector. |
b |
vec3 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | The first matrix. |
b |
mat4 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Tests whether or not the arguments have approximately the same value, within an absolute
or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
than or equal to 1.0, and a relative tolerance is used for larger values)
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | The first number to test. |
b |
Number | The second number to test. |
Returns:
True if the numbers are approximately equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | The first matrix. |
b |
mat2 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | The first matrix. |
b |
mat3 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | The first vector. |
b |
vec4 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | The first matrix. |
b |
mat2d | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
equals(a, b) → {Boolean}
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | The first vector. |
b |
vec2 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | The first vector. |
b |
vec2 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | The first vector. |
b |
vec3 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | The first matrix. |
b |
mat2d | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | The first matrix. |
b |
mat4 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | The first matrix. |
b |
mat2 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | The first vector. |
b |
vec4 | The second vector. |
Returns:
True if the vectors are equal, false otherwise.
- Type
- Boolean
exactEquals(a, b) → {Boolean}
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | The first matrix. |
b |
mat3 | The second matrix. |
Returns:
True if the matrices are equal, false otherwise.
- Type
- Boolean
floor(out, a) → {vec3}
Math.floor the components of a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to floor |
Returns:
out
- Type
- vec3
floor(out, a) → {vec2}
Math.floor the components of a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to floor |
Returns:
out
- Type
- vec2
floor(out, a) → {vec4}
Math.floor the components of a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to floor |
Returns:
out
- Type
- vec4
frob(a) → {Number}
Returns Frobenius norm of a mat2
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | the matrix to calculate Frobenius norm of |
Returns:
Frobenius norm
- Type
- Number
frob(a) → {Number}
Returns Frobenius norm of a mat4
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | the matrix to calculate Frobenius norm of |
Returns:
Frobenius norm
- Type
- Number
frob(a) → {Number}
Returns Frobenius norm of a mat2d
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | the matrix to calculate Frobenius norm of |
Returns:
Frobenius norm
- Type
- Number
frob(a) → {Number}
Returns Frobenius norm of a mat3
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | the matrix to calculate Frobenius norm of |
Returns:
Frobenius norm
- Type
- Number
fromMat2d(out, a) → {mat3}
Copies the values from a mat2d into a mat3
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat2d | the matrix to copy |
Returns:
out
- Type
- mat3
fromMat3(out, m) → {quat}
Creates a quaternion from the given 3x3 rotation matrix.
NOTE: The resultant quaternion is not normalized, so you should be sure
to renormalize the quaternion yourself where necessary.
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
m |
mat3 | rotation matrix |
Returns:
out
- Type
- quat
fromMat4(out, a) → {mat3}
Copies the upper-left 3x3 values into the given mat3.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving 3x3 matrix |
a |
mat4 | the source 4x4 matrix |
Returns:
out
- Type
- mat3
fromQuat(out, q) → {mat3}
Calculates a 3x3 matrix from the given quaternion
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | mat3 receiving operation result |
q |
quat | Quaternion to create matrix from |
Returns:
out
- Type
- mat3
fromQuat(out, q) → {mat4}
Calculates a 4x4 matrix from the given quaternion
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
q |
quat | Quaternion to create matrix from |
Returns:
out
- Type
- mat4
fromRotation(out, rad) → {mat3}
Creates a matrix from a given angle
This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.rotate(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | mat3 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat3
fromRotation(out, rad) → {mat2d}
Creates a matrix from a given angle
This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.rotate(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | mat2d receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat2d
fromRotation(out, rad) → {mat2}
Creates a matrix from a given angle
This is equivalent to (but much faster than):
mat2.identity(dest);
mat2.rotate(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | mat2 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat2
fromRotation(out, rad, axis) → {mat4}
Creates a matrix from a given angle around a given axis
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.rotate(dest, dest, rad, axis);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
axis |
vec3 | the axis to rotate around |
Returns:
out
- Type
- mat4
fromRotationTranslation(out, q, v) → {mat4}
Creates a matrix from a quaternion rotation and vector translation
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
q |
quat4 | Rotation quaternion |
v |
vec3 | Translation vector |
Returns:
out
- Type
- mat4
fromRotationTranslationScale(out, q, v, s) → {mat4}
Creates a matrix from a quaternion rotation, vector translation and vector scale
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
q |
quat4 | Rotation quaternion |
v |
vec3 | Translation vector |
s |
vec3 | Scaling vector |
Returns:
out
- Type
- mat4
fromRotationTranslationScaleOrigin(out, q, v, s, o) → {mat4}
Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
mat4.translate(dest, origin);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
mat4.translate(dest, negativeOrigin);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
q |
quat4 | Rotation quaternion |
v |
vec3 | Translation vector |
s |
vec3 | Scaling vector |
o |
vec3 | The origin vector around which to scale and rotate |
Returns:
out
- Type
- mat4
fromScaling(out, v) → {mat2}
Creates a matrix from a vector scaling
This is equivalent to (but much faster than):
mat2.identity(dest);
mat2.scale(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | mat2 receiving operation result |
v |
vec2 | Scaling vector |
Returns:
out
- Type
- mat2
fromScaling(out, v) → {mat2d}
Creates a matrix from a vector scaling
This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.scale(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | mat2d receiving operation result |
v |
vec2 | Scaling vector |
Returns:
out
- Type
- mat2d
fromScaling(out, v) → {mat3}
Creates a matrix from a vector scaling
This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.scale(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | mat3 receiving operation result |
v |
vec2 | Scaling vector |
Returns:
out
- Type
- mat3
fromScaling(out, v) → {mat4}
Creates a matrix from a vector scaling
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.scale(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
v |
vec3 | Scaling vector |
Returns:
out
- Type
- mat4
fromTranslation(out, v) → {mat2d}
Creates a matrix from a vector translation
This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.translate(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | mat2d receiving operation result |
v |
vec2 | Translation vector |
Returns:
out
- Type
- mat2d
fromTranslation(out, v) → {mat4}
Creates a matrix from a vector translation
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
v |
vec3 | Translation vector |
Returns:
out
- Type
- mat4
fromTranslation(out, v) → {mat3}
Creates a matrix from a vector translation
This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.translate(dest, dest, vec);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | mat3 receiving operation result |
v |
vec2 | Translation vector |
Returns:
out
- Type
- mat3
fromValues(a, b, c, d, tx, ty) → {mat2d}
Create a new mat2d with the given values
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | Component A (index 0) |
b |
Number | Component B (index 1) |
c |
Number | Component C (index 2) |
d |
Number | Component D (index 3) |
tx |
Number | Component TX (index 4) |
ty |
Number | Component TY (index 5) |
Returns:
A new mat2d
- Type
- mat2d
fromValues(x, y, z) → {vec3}
Creates a new vec3 initialized with the given values
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | X component |
y |
Number | Y component |
z |
Number | Z component |
Returns:
a new 3D vector
- Type
- vec3
fromValues(m00, m01, m10, m11) → {mat2}
Create a new mat2 with the given values
Parameters:
Name | Type | Description |
---|---|---|
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m10 |
Number | Component in column 1, row 0 position (index 2) |
m11 |
Number | Component in column 1, row 1 position (index 3) |
Returns:
out A new 2x2 matrix
- Type
- mat2
fromValues(x, y) → {vec2}
Creates a new vec2 initialized with the given values
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | X component |
y |
Number | Y component |
Returns:
a new 2D vector
- Type
- vec2
fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) → {mat4}
Create a new mat4 with the given values
Parameters:
Name | Type | Description |
---|---|---|
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m02 |
Number | Component in column 0, row 2 position (index 2) |
m03 |
Number | Component in column 0, row 3 position (index 3) |
m10 |
Number | Component in column 1, row 0 position (index 4) |
m11 |
Number | Component in column 1, row 1 position (index 5) |
m12 |
Number | Component in column 1, row 2 position (index 6) |
m13 |
Number | Component in column 1, row 3 position (index 7) |
m20 |
Number | Component in column 2, row 0 position (index 8) |
m21 |
Number | Component in column 2, row 1 position (index 9) |
m22 |
Number | Component in column 2, row 2 position (index 10) |
m23 |
Number | Component in column 2, row 3 position (index 11) |
m30 |
Number | Component in column 3, row 0 position (index 12) |
m31 |
Number | Component in column 3, row 1 position (index 13) |
m32 |
Number | Component in column 3, row 2 position (index 14) |
m33 |
Number | Component in column 3, row 3 position (index 15) |
Returns:
A new mat4
- Type
- mat4
fromValues(x, y, z, w) → {vec4}
Creates a new vec4 initialized with the given values
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | X component |
y |
Number | Y component |
z |
Number | Z component |
w |
Number | W component |
Returns:
a new 4D vector
- Type
- vec4
fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) → {mat3}
Create a new mat3 with the given values
Parameters:
Name | Type | Description |
---|---|---|
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m02 |
Number | Component in column 0, row 2 position (index 2) |
m10 |
Number | Component in column 1, row 0 position (index 3) |
m11 |
Number | Component in column 1, row 1 position (index 4) |
m12 |
Number | Component in column 1, row 2 position (index 5) |
m20 |
Number | Component in column 2, row 0 position (index 6) |
m21 |
Number | Component in column 2, row 1 position (index 7) |
m22 |
Number | Component in column 2, row 2 position (index 8) |
Returns:
A new mat3
- Type
- mat3
fromXRotation(out, rad) → {mat4}
Creates a matrix from the given angle around the X axis
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.rotateX(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
fromYRotation(out, rad) → {mat4}
Creates a matrix from the given angle around the Y axis
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.rotateY(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
fromZRotation(out, rad) → {mat4}
Creates a matrix from the given angle around the Z axis
This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.rotateZ(dest, dest, rad);
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 receiving operation result |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
frustum(out, left, right, bottom, top, near, far) → {mat4}
Generates a frustum matrix with the given bounds
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 frustum matrix will be written into |
left |
Number | Left bound of the frustum |
right |
Number | Right bound of the frustum |
bottom |
Number | Bottom bound of the frustum |
top |
Number | Top bound of the frustum |
near |
Number | Near bound of the frustum |
far |
Number | Far bound of the frustum |
Returns:
out
- Type
- mat4
getAxisAngle(out_axis, q) → {Number}
Gets the rotation axis and angle for a given
quaternion. If a quaternion is created with
setAxisAngle, this method will return the same
values as providied in the original parameter list
OR functionally equivalent values.
Example: The quaternion formed by axis [0, 0, 1] and
angle -90 is the same as the quaternion formed by
[0, 0, 1] and 270. This method favors the latter.
Parameters:
Name | Type | Description |
---|---|---|
out_axis |
vec3 | Vector receiving the axis of rotation |
q |
quat | Quaternion to be decomposed |
Returns:
Angle, in radians, of the rotation
- Type
- Number
getRotation(out, mat) → {quat}
Returns a quaternion representing the rotational component
of a transformation matrix. If a matrix is built with
fromRotationTranslation, the returned quaternion will be the
same as the quaternion originally supplied.
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | Quaternion to receive the rotation component |
mat |
mat4 | Matrix to be decomposed (input) |
Returns:
out
- Type
- quat
getScaling(out, mat) → {vec3}
Returns the scaling factor component of a transformation
matrix. If a matrix is built with fromRotationTranslationScale
with a normalized Quaternion paramter, the returned vector will be
the same as the scaling vector
originally supplied.
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | Vector to receive scaling factor component |
mat |
mat4 | Matrix to be decomposed (input) |
Returns:
out
- Type
- vec3
getTranslation(out, mat) → {vec3}
Returns the translation vector component of a transformation
matrix. If a matrix is built with fromRotationTranslation,
the returned vector will be the same as the translation vector
originally supplied.
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | Vector to receive translation component |
mat |
mat4 | Matrix to be decomposed (input) |
Returns:
out
- Type
- vec3
hermite(out, a, b, c, d, t) → {vec3}
Performs a hermite interpolation with two control points
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
c |
vec3 | the third operand |
d |
vec3 | the fourth operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- vec3
identity(out) → {mat2d}
Set a mat2d to the identity matrix
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
Returns:
out
- Type
- mat2d
identity(out) → {quat}
Set a quat to the identity quaternion
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
Returns:
out
- Type
- quat
identity(out) → {mat3}
Set a mat3 to the identity matrix
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
Returns:
out
- Type
- mat3
identity(out) → {mat4}
Set a mat4 to the identity matrix
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
Returns:
out
- Type
- mat4
identity(out) → {mat2}
Set a mat2 to the identity matrix
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
Returns:
out
- Type
- mat2
inverse(out, a) → {vec3}
Returns the inverse of the components of a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to invert |
Returns:
out
- Type
- vec3
inverse(out, a) → {vec2}
Returns the inverse of the components of a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to invert |
Returns:
out
- Type
- vec2
inverse(out, a) → {vec4}
Returns the inverse of the components of a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to invert |
Returns:
out
- Type
- vec4
invert(out, a) → {mat4}
Inverts a mat4
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the source matrix |
Returns:
out
- Type
- mat4
invert(out, a) → {mat3}
Inverts a mat3
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the source matrix |
Returns:
out
- Type
- mat3
invert(out, a) → {quat}
Calculates the inverse of a quat
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
a |
quat | quat to calculate inverse of |
Returns:
out
- Type
- quat
invert(out, a) → {mat2}
Inverts a mat2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the source matrix |
Returns:
out
- Type
- mat2
invert(out, a) → {mat2d}
Inverts a mat2d
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the source matrix |
Returns:
out
- Type
- mat2d
LDU(L, D, U, a)
Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
Parameters:
Name | Type | Description |
---|---|---|
L |
mat2 | the lower triangular matrix |
D |
mat2 | the diagonal matrix |
U |
mat2 | the upper triangular matrix |
a |
mat2 | the input matrix to factorize |
len(a) → {Number}
Calculates the length of a quat
Parameters:
Name | Type | Description |
---|---|---|
a |
quat | vector to calculate length of |
Returns:
length of a
- Type
- Number
len(a) → {Number}
Calculates the length of a vec4
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | vector to calculate length of |
Returns:
length of a
- Type
- Number
len(a) → {Number}
Calculates the length of a vec3
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | vector to calculate length of |
Returns:
length of a
- Type
- Number
len(a) → {Number}
Calculates the length of a vec2
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | vector to calculate length of |
Returns:
length of a
- Type
- Number
lerp(out, a, b, t) → {vec4}
Performs a linear interpolation between two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- vec4
lerp(out, a, b, t) → {vec2}
Performs a linear interpolation between two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- vec2
lerp(out, a, b, t) → {vec3}
Performs a linear interpolation between two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- vec3
lookAt(out, eye, center, up) → {mat4}
Generates a look-at matrix with the given eye position, focal point, and up axis
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 frustum matrix will be written into |
eye |
vec3 | Position of the viewer |
center |
vec3 | Point the viewer is looking at |
up |
vec3 | vec3 pointing up |
Returns:
out
- Type
- mat4
max(out, a, b) → {vec3}
Returns the maximum of two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
max(out, a, b) → {vec4}
Returns the maximum of two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
max(out, a, b) → {vec2}
Returns the maximum of two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
min(out, a, b) → {vec3}
Returns the minimum of two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
min(out, a, b) → {vec4}
Returns the minimum of two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
min(out, a, b) → {vec2}
Returns the minimum of two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
multiply(out, a, b) → {quat}
Multiplies two quat's
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
a |
quat | the first operand |
b |
quat | the second operand |
Returns:
out
- Type
- quat
multiply(out, a, b) → {mat2}
Multiplies two mat2's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the first operand |
b |
mat2 | the second operand |
Returns:
out
- Type
- mat2
multiply(out, a, b) → {mat2d}
Multiplies two mat2d's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the first operand |
b |
mat2d | the second operand |
Returns:
out
- Type
- mat2d
multiply(out, a, b) → {mat4}
Multiplies two mat4s
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the first operand |
b |
mat4 | the second operand |
Returns:
out
- Type
- mat4
multiply(out, a, b) → {vec2}
Multiplies two vec2's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
multiply(out, a, b) → {vec4}
Multiplies two vec4's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
multiply(out, a, b) → {vec3}
Multiplies two vec3's
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
multiply(out, a, b) → {mat3}
Multiplies two mat3's
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the first operand |
b |
mat3 | the second operand |
Returns:
out
- Type
- mat3
multiplyScalar(out, a, b) → {mat2}
Multiply each element of the matrix by a scalar.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the matrix to scale |
b |
Number | amount to scale the matrix's elements by |
Returns:
out
- Type
- mat2
multiplyScalar(out, a, b) → {mat2d}
Multiply each element of the matrix by a scalar.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the matrix to scale |
b |
Number | amount to scale the matrix's elements by |
Returns:
out
- Type
- mat2d
multiplyScalar(out, a, b) → {mat4}
Multiply each element of the matrix by a scalar.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to scale |
b |
Number | amount to scale the matrix's elements by |
Returns:
out
- Type
- mat4
multiplyScalar(out, a, b) → {mat3}
Multiply each element of the matrix by a scalar.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the matrix to scale |
b |
Number | amount to scale the matrix's elements by |
Returns:
out
- Type
- mat3
multiplyScalarAndAdd(out, a, b, scale) → {mat3}
Adds two mat3's after multiplying each element of the second operand by a scalar value.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving vector |
a |
mat3 | the first operand |
b |
mat3 | the second operand |
scale |
Number | the amount to scale b's elements by before adding |
Returns:
out
- Type
- mat3
multiplyScalarAndAdd(out, a, b, scale) → {mat2}
Adds two mat2's after multiplying each element of the second operand by a scalar value.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving vector |
a |
mat2 | the first operand |
b |
mat2 | the second operand |
scale |
Number | the amount to scale b's elements by before adding |
Returns:
out
- Type
- mat2
multiplyScalarAndAdd(out, a, b, scale) → {mat2d}
Adds two mat2d's after multiplying each element of the second operand by a scalar value.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving vector |
a |
mat2d | the first operand |
b |
mat2d | the second operand |
scale |
Number | the amount to scale b's elements by before adding |
Returns:
out
- Type
- mat2d
multiplyScalarAndAdd(out, a, b, scale) → {mat4}
Adds two mat4's after multiplying each element of the second operand by a scalar value.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving vector |
a |
mat4 | the first operand |
b |
mat4 | the second operand |
scale |
Number | the amount to scale b's elements by before adding |
Returns:
out
- Type
- mat4
negate(out, a) → {vec4}
Negates the components of a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to negate |
Returns:
out
- Type
- vec4
negate(out, a) → {vec2}
Negates the components of a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to negate |
Returns:
out
- Type
- vec2
negate(out, a) → {vec3}
Negates the components of a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to negate |
Returns:
out
- Type
- vec3
normalFromMat4(out, a) → {mat3}
Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | mat3 receiving operation result |
a |
mat4 | Mat4 to derive the normal matrix from |
Returns:
out
- Type
- mat3
normalize(out, a) → {vec4}
Normalize a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to normalize |
Returns:
out
- Type
- vec4
normalize(out, a) → {vec3}
Normalize a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to normalize |
Returns:
out
- Type
- vec3
normalize(out, a) → {vec2}
Normalize a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to normalize |
Returns:
out
- Type
- vec2
ortho(out, left, right, bottom, top, near, far) → {mat4}
Generates a orthogonal projection matrix with the given bounds
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 frustum matrix will be written into |
left |
number | Left bound of the frustum |
right |
number | Right bound of the frustum |
bottom |
number | Bottom bound of the frustum |
top |
number | Top bound of the frustum |
near |
number | Near bound of the frustum |
far |
number | Far bound of the frustum |
Returns:
out
- Type
- mat4
perspective(out, fovy, aspect, near, far) → {mat4}
Generates a perspective projection matrix with the given bounds
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 frustum matrix will be written into |
fovy |
number | Vertical field of view in radians |
aspect |
number | Aspect ratio. typically viewport width/height |
near |
number | Near bound of the frustum |
far |
number | Far bound of the frustum |
Returns:
out
- Type
- mat4
perspectiveFromFieldOfView(out, fov, near, far) → {mat4}
Generates a perspective projection matrix with the given field of view.
This is primarily useful for generating projection matrices to be used
with the still experiemental WebVR API.
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | mat4 frustum matrix will be written into |
fov |
Object | Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees |
near |
number | Near bound of the frustum |
far |
number | Far bound of the frustum |
Returns:
out
- Type
- mat4
random(out, scaleopt) → {vec4}
Generates a random vector with the given scale
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
out |
vec4 | the receiving vector | |
scale |
Number |
<optional> |
Length of the resulting vector. If ommitted, a unit vector will be returned |
Returns:
out
- Type
- vec4
random(out, scaleopt) → {vec2}
Generates a random vector with the given scale
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
out |
vec2 | the receiving vector | |
scale |
Number |
<optional> |
Length of the resulting vector. If ommitted, a unit vector will be returned |
Returns:
out
- Type
- vec2
random(out, scaleopt) → {vec3}
Generates a random vector with the given scale
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
out |
vec3 | the receiving vector | |
scale |
Number |
<optional> |
Length of the resulting vector. If ommitted, a unit vector will be returned |
Returns:
out
- Type
- vec3
rotate(out, a, rad, axis) → {mat4}
Rotates a mat4 by the given angle around the given axis
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
axis |
vec3 | the axis to rotate around |
Returns:
out
- Type
- mat4
rotate(out, a, rad) → {mat3}
Rotates a mat3 by the given angle
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat3
rotate(out, a, rad) → {mat2}
Rotates a mat2 by the given angle
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat2
rotate(out, a, rad) → {mat2d}
Rotates a mat2d by the given angle
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat2d
rotateX(out, a, b, c) → {vec3}
Rotate a 3D vector around the x-axis
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | The receiving vec3 |
a |
vec3 | The vec3 point to rotate |
b |
vec3 | The origin of the rotation |
c |
Number | The angle of rotation |
Returns:
out
- Type
- vec3
rotateX(out, a, rad) → {mat4}
Rotates a matrix by the given angle around the X axis
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
rotateX(out, a, rad) → {quat}
Rotates a quaternion by the given angle about the X axis
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | quat receiving operation result |
a |
quat | quat to rotate |
rad |
number | angle (in radians) to rotate |
Returns:
out
- Type
- quat
rotateY(out, a, b, c) → {vec3}
Rotate a 3D vector around the y-axis
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | The receiving vec3 |
a |
vec3 | The vec3 point to rotate |
b |
vec3 | The origin of the rotation |
c |
Number | The angle of rotation |
Returns:
out
- Type
- vec3
rotateY(out, a, rad) → {mat4}
Rotates a matrix by the given angle around the Y axis
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
rotateY(out, a, rad) → {quat}
Rotates a quaternion by the given angle about the Y axis
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | quat receiving operation result |
a |
quat | quat to rotate |
rad |
number | angle (in radians) to rotate |
Returns:
out
- Type
- quat
rotateZ(out, a, rad) → {quat}
Rotates a quaternion by the given angle about the Z axis
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | quat receiving operation result |
a |
quat | quat to rotate |
rad |
number | angle (in radians) to rotate |
Returns:
out
- Type
- quat
rotateZ(out, a, rad) → {mat4}
Rotates a matrix by the given angle around the Z axis
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to rotate |
rad |
Number | the angle to rotate the matrix by |
Returns:
out
- Type
- mat4
rotateZ(out, a, b, c) → {vec3}
Rotate a 3D vector around the z-axis
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | The receiving vec3 |
a |
vec3 | The vec3 point to rotate |
b |
vec3 | The origin of the rotation |
c |
Number | The angle of rotation |
Returns:
out
- Type
- vec3
round(out, a) → {vec4}
Math.round the components of a vec4
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | vector to round |
Returns:
out
- Type
- vec4
round(out, a) → {vec2}
Math.round the components of a vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | vector to round |
Returns:
out
- Type
- vec2
round(out, a) → {vec3}
Math.round the components of a vec3
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | vector to round |
Returns:
out
- Type
- vec3
scale(out, a, v) → {mat2}
Scales the mat2 by the dimensions in the given vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the matrix to rotate |
v |
vec2 | the vec2 to scale the matrix by |
Returns:
out
- Type
- mat2
scale(out, a, v) → {mat2d}
Scales the mat2d by the dimensions in the given vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the matrix to translate |
v |
vec2 | the vec2 to scale the matrix by |
Returns:
out
- Type
- mat2d
scale(out, a, b) → {vec2}
Scales a vec2 by a scalar number
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the vector to scale |
b |
Number | amount to scale the vector by |
Returns:
out
- Type
- vec2
scale(out, a, v) → {mat4}
Scales the mat4 by the dimensions in the given vec3 not using vectorization
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to scale |
v |
vec3 | the vec3 to scale the matrix by |
Returns:
out
- Type
- mat4
scale(out, a, v) → {mat3}
Scales the mat3 by the dimensions in the given vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the matrix to rotate |
v |
vec2 | the vec2 to scale the matrix by |
Returns:
out
- Type
- mat3
scale(out, a, b) → {vec3}
Scales a vec3 by a scalar number
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the vector to scale |
b |
Number | amount to scale the vector by |
Returns:
out
- Type
- vec3
scale(out, a, b) → {vec4}
Scales a vec4 by a scalar number
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the vector to scale |
b |
Number | amount to scale the vector by |
Returns:
out
- Type
- vec4
scaleAndAdd(out, a, b, scale) → {vec3}
Adds two vec3's after scaling the second operand by a scalar value
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
scale |
Number | the amount to scale b by before adding |
Returns:
out
- Type
- vec3
scaleAndAdd(out, a, b, scale) → {vec4}
Adds two vec4's after scaling the second operand by a scalar value
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
scale |
Number | the amount to scale b by before adding |
Returns:
out
- Type
- vec4
scaleAndAdd(out, a, b, scale) → {vec2}
Adds two vec2's after scaling the second operand by a scalar value
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
scale |
Number | the amount to scale b by before adding |
Returns:
out
- Type
- vec2
set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) → {mat4}
Set the components of a mat4 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m02 |
Number | Component in column 0, row 2 position (index 2) |
m03 |
Number | Component in column 0, row 3 position (index 3) |
m10 |
Number | Component in column 1, row 0 position (index 4) |
m11 |
Number | Component in column 1, row 1 position (index 5) |
m12 |
Number | Component in column 1, row 2 position (index 6) |
m13 |
Number | Component in column 1, row 3 position (index 7) |
m20 |
Number | Component in column 2, row 0 position (index 8) |
m21 |
Number | Component in column 2, row 1 position (index 9) |
m22 |
Number | Component in column 2, row 2 position (index 10) |
m23 |
Number | Component in column 2, row 3 position (index 11) |
m30 |
Number | Component in column 3, row 0 position (index 12) |
m31 |
Number | Component in column 3, row 1 position (index 13) |
m32 |
Number | Component in column 3, row 2 position (index 14) |
m33 |
Number | Component in column 3, row 3 position (index 15) |
Returns:
out
- Type
- mat4
set(out, m00, m01, m10, m11) → {mat2}
Set the components of a mat2 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m10 |
Number | Component in column 1, row 0 position (index 2) |
m11 |
Number | Component in column 1, row 1 position (index 3) |
Returns:
out
- Type
- mat2
set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) → {mat3}
Set the components of a mat3 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
m00 |
Number | Component in column 0, row 0 position (index 0) |
m01 |
Number | Component in column 0, row 1 position (index 1) |
m02 |
Number | Component in column 0, row 2 position (index 2) |
m10 |
Number | Component in column 1, row 0 position (index 3) |
m11 |
Number | Component in column 1, row 1 position (index 4) |
m12 |
Number | Component in column 1, row 2 position (index 5) |
m20 |
Number | Component in column 2, row 0 position (index 6) |
m21 |
Number | Component in column 2, row 1 position (index 7) |
m22 |
Number | Component in column 2, row 2 position (index 8) |
Returns:
out
- Type
- mat3
set(out, a, b, c, d, tx, ty) → {mat2d}
Set the components of a mat2d to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
Number | Component A (index 0) |
b |
Number | Component B (index 1) |
c |
Number | Component C (index 2) |
d |
Number | Component D (index 3) |
tx |
Number | Component TX (index 4) |
ty |
Number | Component TY (index 5) |
Returns:
out
- Type
- mat2d
set(out, x, y) → {vec2}
Set the components of a vec2 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
x |
Number | X component |
y |
Number | Y component |
Returns:
out
- Type
- vec2
set(out, x, y, z) → {vec3}
Set the components of a vec3 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
x |
Number | X component |
y |
Number | Y component |
z |
Number | Z component |
Returns:
out
- Type
- vec3
set(out, x, y, z, w) → {vec4}
Set the components of a vec4 to the given values
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
x |
Number | X component |
y |
Number | Y component |
z |
Number | Z component |
w |
Number | W component |
Returns:
out
- Type
- vec4
setAxisAngle(out, axis, rad) → {quat}
Sets a quat from the given angle and rotation axis,
then returns it.
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
axis |
vec3 | the axis around which to rotate |
rad |
Number | the angle in radians |
Returns:
out
- Type
- quat
setMatrixArrayType(type)
Sets the type of array used when creating new vectors and matrices
Parameters:
Name | Type | Description |
---|---|---|
type |
Type | Array type, such as Float32Array or Array |
slerp(out, a, b, t) → {quat}
Performs a spherical linear interpolation between two quat
Parameters:
Name | Type | Description |
---|---|---|
out |
quat | the receiving quaternion |
a |
quat | the first operand |
b |
quat | the second operand |
t |
Number | interpolation amount between the two inputs |
Returns:
out
- Type
- quat
squaredDistance(a, b) → {Number}
Calculates the squared euclidian distance between two vec2's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
squared distance between a and b
- Type
- Number
squaredDistance(a, b) → {Number}
Calculates the squared euclidian distance between two vec3's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
squared distance between a and b
- Type
- Number
squaredDistance(a, b) → {Number}
Calculates the squared euclidian distance between two vec4's
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
squared distance between a and b
- Type
- Number
squaredLength(a) → {Number}
Calculates the squared length of a vec4
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | vector to calculate squared length of |
Returns:
squared length of a
- Type
- Number
squaredLength(a) → {Number}
Calculates the squared length of a vec2
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | vector to calculate squared length of |
Returns:
squared length of a
- Type
- Number
squaredLength(a) → {Number}
Calculates the squared length of a vec3
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | vector to calculate squared length of |
Returns:
squared length of a
- Type
- Number
str(a) → {String}
Returns a string representation of a mat2
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2 | matrix to represent as a string |
Returns:
string representation of the matrix
- Type
- String
str(a) → {String}
Returns a string representation of a vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec2 | vector to represent as a string |
Returns:
string representation of the vector
- Type
- String
str(a) → {String}
Returns a string representation of a mat4
Parameters:
Name | Type | Description |
---|---|---|
a |
mat4 | matrix to represent as a string |
Returns:
string representation of the matrix
- Type
- String
str(a) → {String}
Returns a string representation of a vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec4 | vector to represent as a string |
Returns:
string representation of the vector
- Type
- String
str(a) → {String}
Returns a string representation of a quatenion
Parameters:
Name | Type | Description |
---|---|---|
a |
quat | vector to represent as a string |
Returns:
string representation of the vector
- Type
- String
str(a) → {String}
Returns a string representation of a mat3
Parameters:
Name | Type | Description |
---|---|---|
a |
mat3 | matrix to represent as a string |
Returns:
string representation of the matrix
- Type
- String
str(a) → {String}
Returns a string representation of a vector
Parameters:
Name | Type | Description |
---|---|---|
a |
vec3 | vector to represent as a string |
Returns:
string representation of the vector
- Type
- String
str(a) → {String}
Returns a string representation of a mat2d
Parameters:
Name | Type | Description |
---|---|---|
a |
mat2d | matrix to represent as a string |
Returns:
string representation of the matrix
- Type
- String
subtract(out, a, b) → {vec2}
Subtracts vector b from vector a
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the first operand |
b |
vec2 | the second operand |
Returns:
out
- Type
- vec2
subtract(out, a, b) → {mat2}
Subtracts matrix b from matrix a
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the first operand |
b |
mat2 | the second operand |
Returns:
out
- Type
- mat2
subtract(out, a, b) → {vec3}
Subtracts vector b from vector a
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the first operand |
b |
vec3 | the second operand |
Returns:
out
- Type
- vec3
subtract(out, a, b) → {mat2d}
Subtracts matrix b from matrix a
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the first operand |
b |
mat2d | the second operand |
Returns:
out
- Type
- mat2d
subtract(out, a, b) → {mat4}
Subtracts matrix b from matrix a
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the first operand |
b |
mat4 | the second operand |
Returns:
out
- Type
- mat4
subtract(out, a, b) → {vec4}
Subtracts vector b from vector a
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the first operand |
b |
vec4 | the second operand |
Returns:
out
- Type
- vec4
subtract(out, a, b) → {mat3}
Subtracts matrix b from matrix a
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the first operand |
b |
mat3 | the second operand |
Returns:
out
- Type
- mat3
toRadian(a)
Convert Degree To Radian
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | Angle in Degrees |
transformMat2(out, a, m) → {vec2}
Transforms the vec2 with a mat2
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the vector to transform |
m |
mat2 | matrix to transform with |
Returns:
out
- Type
- vec2
transformMat2d(out, a, m) → {vec2}
Transforms the vec2 with a mat2d
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the vector to transform |
m |
mat2d | matrix to transform with |
Returns:
out
- Type
- vec2
transformMat3(out, a, m) → {vec3}
Transforms the vec3 with a mat3.
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the vector to transform |
m |
mat4 | the 3x3 matrix to transform with |
Returns:
out
- Type
- vec3
transformMat3(out, a, m) → {vec2}
Transforms the vec2 with a mat3
3rd vector component is implicitly '1'
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the vector to transform |
m |
mat3 | matrix to transform with |
Returns:
out
- Type
- vec2
transformMat4(out, a, m) → {vec2}
Transforms the vec2 with a mat4
3rd vector component is implicitly '0'
4th vector component is implicitly '1'
Parameters:
Name | Type | Description |
---|---|---|
out |
vec2 | the receiving vector |
a |
vec2 | the vector to transform |
m |
mat4 | matrix to transform with |
Returns:
out
- Type
- vec2
transformMat4(out, a, m) → {vec3}
Transforms the vec3 with a mat4.
4th vector component is implicitly '1'
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the vector to transform |
m |
mat4 | matrix to transform with |
Returns:
out
- Type
- vec3
transformMat4(out, a, m) → {vec4}
Transforms the vec4 with a mat4.
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the vector to transform |
m |
mat4 | matrix to transform with |
Returns:
out
- Type
- vec4
transformQuat(out, a, q) → {vec3}
Transforms the vec3 with a quat
Parameters:
Name | Type | Description |
---|---|---|
out |
vec3 | the receiving vector |
a |
vec3 | the vector to transform |
q |
quat | quaternion to transform with |
Returns:
out
- Type
- vec3
transformQuat(out, a, q) → {vec4}
Transforms the vec4 with a quat
Parameters:
Name | Type | Description |
---|---|---|
out |
vec4 | the receiving vector |
a |
vec4 | the vector to transform |
q |
quat | quaternion to transform with |
Returns:
out
- Type
- vec4
translate(out, a, v) → {mat4}
Translate a mat4 by the given vector
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the matrix to translate |
v |
vec3 | vector to translate by |
Returns:
out
- Type
- mat4
translate(out, a, v) → {mat2d}
Translates the mat2d by the dimensions in the given vec2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2d | the receiving matrix |
a |
mat2d | the matrix to translate |
v |
vec2 | the vec2 to translate the matrix by |
Returns:
out
- Type
- mat2d
translate(out, a, v) → {mat3}
Translate a mat3 by the given vector
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the matrix to translate |
v |
vec2 | vector to translate by |
Returns:
out
- Type
- mat3
transpose(out, a) → {mat3}
Transpose the values of a mat3
Parameters:
Name | Type | Description |
---|---|---|
out |
mat3 | the receiving matrix |
a |
mat3 | the source matrix |
Returns:
out
- Type
- mat3
transpose(out, a) → {mat2}
Transpose the values of a mat2
Parameters:
Name | Type | Description |
---|---|---|
out |
mat2 | the receiving matrix |
a |
mat2 | the source matrix |
Returns:
out
- Type
- mat2
transpose(out, a) → {mat4}
Transpose the values of a mat4
Parameters:
Name | Type | Description |
---|---|---|
out |
mat4 | the receiving matrix |
a |
mat4 | the source matrix |
Returns:
out
- Type
- mat4