Javascript Matrix and Vector library for High Performance WebGL apps
Sets the type of array used when creating new vectors and matrices
Name | Type | Description | |
---|---|---|---|
type |
Type
|
Array type, such as Float32Array or Array |
Void
Convert Degree To Radian
Name | Type | Description | |
---|---|---|---|
a |
Number
|
Angle in Degrees |
Void
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)
Name | Type | Description | |
---|---|---|---|
a |
Number
|
The first number to test. |
|
b |
Number
|
The second number to test. |
Boolean
True if the numbers are approximately equal, false otherwise.
Creates a new mat2 initialized with values from an existing matrix
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
matrix to clone |
mat2
a new 2x2 matrix
Copy the values from one mat2 to another
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the source matrix |
mat2
out
Set a mat2 to the identity matrix
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
mat2
out
Create a new mat2 with the given values
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) |
mat2
out A new 2x2 matrix
Set the components of a mat2 to the given values
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) |
mat2
out
Transpose the values of a mat2
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the source matrix |
mat2
out
Inverts a mat2
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the source matrix |
mat2
out
Calculates the adjugate of a mat2
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the source matrix |
mat2
out
Calculates the determinant of a mat2
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
the source matrix |
Number
determinant of a
Multiplies two mat2's
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the first operand |
|
b |
mat2
|
the second operand |
mat2
out
Rotates a mat2 by the given angle
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat2
out
Scales the mat2 by the dimensions in the given vec2
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the matrix to rotate |
|
v |
vec2
|
the vec2 to scale the matrix by |
mat2
out
Creates a matrix from a given angle This is equivalent to (but much faster than):
mat2.identity(dest);
mat2.rotate(dest, dest, rad);
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
mat2 receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat2
out
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat2.identity(dest);
mat2.scale(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
mat2 receiving operation result |
|
v |
vec2
|
Scaling vector |
mat2
out
Returns a string representation of a mat2
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
matrix to represent as a string |
String
string representation of the matrix
Returns Frobenius norm of a mat2
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
the matrix to calculate Frobenius norm of |
Number
Frobenius norm
Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
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 |
Void
Adds two mat2's
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the first operand |
|
b |
mat2
|
the second operand |
mat2
out
Subtracts matrix b from matrix a
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the first operand |
|
b |
mat2
|
the second operand |
mat2
out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
The first matrix. |
|
b |
mat2
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
mat2
|
The first matrix. |
|
b |
mat2
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Multiply each element of the matrix by a scalar.
Name | Type | Description | |
---|---|---|---|
out |
mat2
|
the receiving matrix |
|
a |
mat2
|
the matrix to scale |
|
b |
Number
|
amount to scale the matrix's elements by |
mat2
out
Adds two mat2's after multiplying each element of the second operand by a scalar value.
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 |
mat2
out
Creates a new mat2d initialized with values from an existing matrix
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
matrix to clone |
mat2d
a new 2x3 matrix
Copy the values from one mat2d to another
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the source matrix |
mat2d
out
Set a mat2d to the identity matrix
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
mat2d
out
Create a new mat2d with the given values
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) |
mat2d
A new mat2d
Set the components of a mat2d to the given values
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) |
mat2d
out
Inverts a mat2d
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the source matrix |
mat2d
out
Calculates the determinant of a mat2d
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
the source matrix |
Number
determinant of a
Multiplies two mat2d's
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the first operand |
|
b |
mat2d
|
the second operand |
mat2d
out
Rotates a mat2d by the given angle
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat2d
out
Scales the mat2d by the dimensions in the given vec2
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the matrix to translate |
|
v |
vec2
|
the vec2 to scale the matrix by |
mat2d
out
Translates the mat2d by the dimensions in the given vec2
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the matrix to translate |
|
v |
vec2
|
the vec2 to translate the matrix by |
mat2d
out
Creates a matrix from a given angle This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.rotate(dest, dest, rad);
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
mat2d receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat2d
out
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.scale(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
mat2d receiving operation result |
|
v |
vec2
|
Scaling vector |
mat2d
out
Creates a matrix from a vector translation This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.translate(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
mat2d receiving operation result |
|
v |
vec2
|
Translation vector |
mat2d
out
Returns a string representation of a mat2d
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
matrix to represent as a string |
String
string representation of the matrix
Returns Frobenius norm of a mat2d
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
the matrix to calculate Frobenius norm of |
Number
Frobenius norm
Adds two mat2d's
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the first operand |
|
b |
mat2d
|
the second operand |
mat2d
out
Subtracts matrix b from matrix a
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the first operand |
|
b |
mat2d
|
the second operand |
mat2d
out
Multiply each element of the matrix by a scalar.
Name | Type | Description | |
---|---|---|---|
out |
mat2d
|
the receiving matrix |
|
a |
mat2d
|
the matrix to scale |
|
b |
Number
|
amount to scale the matrix's elements by |
mat2d
out
Adds two mat2d's after multiplying each element of the second operand by a scalar value.
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 |
mat2d
out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
The first matrix. |
|
b |
mat2d
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
mat2d
|
The first matrix. |
|
b |
mat2d
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Copies the upper-left 3x3 values into the given mat3.
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving 3x3 matrix |
|
a |
mat4
|
the source 4x4 matrix |
mat3
out
Creates a new mat3 initialized with values from an existing matrix
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
matrix to clone |
mat3
a new 3x3 matrix
Copy the values from one mat3 to another
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the source matrix |
mat3
out
Create a new mat3 with the given values
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) |
mat3
A new mat3
Set the components of a mat3 to the given values
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) |
mat3
out
Set a mat3 to the identity matrix
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
mat3
out
Transpose the values of a mat3
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the source matrix |
mat3
out
Inverts a mat3
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the source matrix |
mat3
out
Calculates the adjugate of a mat3
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the source matrix |
mat3
out
Calculates the determinant of a mat3
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
the source matrix |
Number
determinant of a
Multiplies two mat3's
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the first operand |
|
b |
mat3
|
the second operand |
mat3
out
Translate a mat3 by the given vector
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the matrix to translate |
|
v |
vec2
|
vector to translate by |
mat3
out
Rotates a mat3 by the given angle
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat3
out
Scales the mat3 by the dimensions in the given vec2
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the matrix to rotate |
|
v |
vec2
|
the vec2 to scale the matrix by |
mat3
out
Creates a matrix from a vector translation This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.translate(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 receiving operation result |
|
v |
vec2
|
Translation vector |
mat3
out
Creates a matrix from a given angle This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.rotate(dest, dest, rad);
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat3
out
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat3.identity(dest);
mat3.scale(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 receiving operation result |
|
v |
vec2
|
Scaling vector |
mat3
out
Copies the values from a mat2d into a mat3
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat2d
|
the matrix to copy |
mat3
out
Calculates a 3x3 matrix from the given quaternion
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 receiving operation result |
|
q |
quat
|
Quaternion to create matrix from |
mat3
out
Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 receiving operation result |
|
a |
mat4
|
Mat4 to derive the normal matrix from |
mat3
out
Generates a 2D projection matrix with the given bounds
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
mat3 frustum matrix will be written into |
|
width |
number
|
Width of your gl context |
|
height |
number
|
Height of gl context |
mat3
out
Returns a string representation of a mat3
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
matrix to represent as a string |
String
string representation of the matrix
Returns Frobenius norm of a mat3
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
the matrix to calculate Frobenius norm of |
Number
Frobenius norm
Adds two mat3's
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the first operand |
|
b |
mat3
|
the second operand |
mat3
out
Subtracts matrix b from matrix a
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the first operand |
|
b |
mat3
|
the second operand |
mat3
out
Multiply each element of the matrix by a scalar.
Name | Type | Description | |
---|---|---|---|
out |
mat3
|
the receiving matrix |
|
a |
mat3
|
the matrix to scale |
|
b |
Number
|
amount to scale the matrix's elements by |
mat3
out
Adds two mat3's after multiplying each element of the second operand by a scalar value.
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 |
mat3
out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
The first matrix. |
|
b |
mat3
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
mat3
|
The first matrix. |
|
b |
mat3
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Creates a new mat4 initialized with values from an existing matrix
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
matrix to clone |
mat4
a new 4x4 matrix
Copy the values from one mat4 to another
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the source matrix |
mat4
out
Create a new mat4 with the given values
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) |
mat4
A new mat4
Set the components of a mat4 to the given values
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) |
mat4
out
Set a mat4 to the identity matrix
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
mat4
out
Transpose the values of a mat4
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the source matrix |
mat4
out
Inverts a mat4
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the source matrix |
mat4
out
Calculates the adjugate of a mat4
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the source matrix |
mat4
out
Calculates the determinant of a mat4
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
the source matrix |
Number
determinant of a
Multiplies two mat4s
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the first operand |
|
b |
mat4
|
the second operand |
mat4
out
Translate a mat4 by the given vector
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to translate |
|
v |
vec3
|
vector to translate by |
mat4
out
Scales the mat4 by the dimensions in the given vec3 not using vectorization
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to scale |
|
v |
vec3
|
the vec3 to scale the matrix by |
mat4
out
Rotates a mat4 by the given angle around the given axis
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 |
mat4
out
Rotates a matrix by the given angle around the X axis
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
Rotates a matrix by the given angle around the Y axis
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
Rotates a matrix by the given angle around the Z axis
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to rotate |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
Creates a matrix from a vector translation This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
v |
vec3
|
Translation vector |
mat4
out
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.scale(dest, dest, vec);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
v |
vec3
|
Scaling vector |
mat4
out
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);
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 |
mat4
out
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);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
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);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
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);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
rad |
Number
|
the angle to rotate the matrix by |
mat4
out
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);
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
q |
quat4
|
Rotation quaternion |
|
v |
vec3
|
Translation vector |
mat4
out
Creates a new mat4 from a dual quat.
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
Matrix |
|
a |
quat2
|
Dual Quaternion |
mat4
mat4 receiving operation result
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.
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
Vector to receive translation component |
|
mat |
mat4
|
Matrix to be decomposed (input) |
vec3
out
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.
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
Vector to receive scaling factor component |
|
mat |
mat4
|
Matrix to be decomposed (input) |
vec3
out
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.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
Quaternion to receive the rotation component |
|
mat |
mat4
|
Matrix to be decomposed (input) |
quat
out
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)
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
q |
quat4
|
Rotation quaternion |
|
v |
vec3
|
Translation vector |
|
s |
vec3
|
Scaling vector |
mat4
out
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);
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 |
mat4
out
Calculates a 4x4 matrix from the given quaternion
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
mat4 receiving operation result |
|
q |
quat
|
Quaternion to create matrix from |
mat4
out
Generates a frustum matrix with the given bounds
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 |
mat4
out
Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.
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, can be null or Infinity |
mat4
out
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.
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 |
mat4
out
Generates a orthogonal projection matrix with the given bounds
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 |
mat4
out
Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
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 |
mat4
out
Generates a matrix that makes something look at something else.
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 |
mat4
out
Returns a string representation of a mat4
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
matrix to represent as a string |
String
string representation of the matrix
Returns Frobenius norm of a mat4
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
the matrix to calculate Frobenius norm of |
Number
Frobenius norm
Adds two mat4's
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the first operand |
|
b |
mat4
|
the second operand |
mat4
out
Subtracts matrix b from matrix a
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the first operand |
|
b |
mat4
|
the second operand |
mat4
out
Multiply each element of the matrix by a scalar.
Name | Type | Description | |
---|---|---|---|
out |
mat4
|
the receiving matrix |
|
a |
mat4
|
the matrix to scale |
|
b |
Number
|
amount to scale the matrix's elements by |
mat4
out
Adds two mat4's after multiplying each element of the second operand by a scalar value.
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 |
mat4
out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
The first matrix. |
|
b |
mat4
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
mat4
|
The first matrix. |
|
b |
mat4
|
The second matrix. |
Boolean
True if the matrices are equal, false otherwise.
Creates a new vec3 initialized with values from an existing vector
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
vector to clone |
vec3
a new 3D vector
Calculates the length of a vec3
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
vector to calculate length of |
Number
length of a
Creates a new vec3 initialized with the given values
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
vec3
a new 3D vector
Copy the values from one vec3 to another
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the source vector |
vec3
out
Set the components of a vec3 to the given values
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
vec3
out
Adds two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Subtracts vector b from vector a
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Multiplies two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Divides two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Math.ceil the components of a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to ceil |
vec3
out
Math.floor the components of a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to floor |
vec3
out
Returns the minimum of two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Returns the maximum of two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Math.round the components of a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to round |
vec3
out
Scales a vec3 by a scalar number
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the vector to scale |
|
b |
Number
|
amount to scale the vector by |
vec3
out
Adds two vec3's after scaling the second operand by a scalar value
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 |
vec3
out
Calculates the euclidian distance between two vec3's
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
Number
distance between a and b
Calculates the squared euclidian distance between two vec3's
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
Number
squared distance between a and b
Calculates the squared length of a vec3
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
vector to calculate squared length of |
Number
squared length of a
Negates the components of a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to negate |
vec3
out
Returns the inverse of the components of a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to invert |
vec3
out
Normalize a vec3
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
vector to normalize |
vec3
out
Calculates the dot product of two vec3's
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
Number
dot product of a and b
Computes the cross product of two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
vec3
out
Performs a linear interpolation between two vec3's
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the first operand |
|
b |
vec3
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
vec3
out
Performs a hermite interpolation with two control points
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, in the range [0-1], between the two inputs |
vec3
out
Performs a bezier interpolation with two control points
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, in the range [0-1], between the two inputs |
vec3
out
Generates a random vector with the given scale
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
scale |
Number
|
Length of the resulting vector. If ommitted, a unit vector will be returned |
Optional |
vec3
out
Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the vector to transform |
|
m |
mat4
|
matrix to transform with |
vec3
out
Transforms the vec3 with a mat3.
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the vector to transform |
|
m |
mat3
|
the 3x3 matrix to transform with |
vec3
out
Transforms the vec3 with a quat Can also be used for dual quaternions. (Multiply it with the real part)
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec3
|
the vector to transform |
|
q |
quat
|
quaternion to transform with |
vec3
out
Rotate a 3D vector around the x-axis
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 |
vec3
out
Rotate a 3D vector around the y-axis
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 |
vec3
out
Rotate a 3D vector around the z-axis
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 |
vec3
out
Get the angle between two 3D vectors
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
The first operand |
|
b |
vec3
|
The second operand |
Number
The angle in radians
Set the components of a vec3 to zero
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
vec3
out
Returns a string representation of a vector
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
vector to represent as a string |
String
string representation of the vector
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
The first vector. |
|
b |
vec3
|
The second vector. |
Boolean
True if the vectors are equal, false otherwise.
Returns whether or not the vectors have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
vec3
|
The first vector. |
|
b |
vec3
|
The second vector. |
Boolean
True if the vectors are equal, false otherwise.
Perform some operation over an array of vec3s.
Name | Type | Description | |
---|---|---|---|
a |
Array
|
the array of vectors to iterate over |
|
stride |
Number
|
Number of elements between the start of each vec3. If 0 assumes tightly packed |
|
offset |
Number
|
Number of elements to skip at the beginning of the array |
|
count |
Number
|
Number of vec3s to iterate over. If 0 iterates over entire array |
|
fn |
Function
|
Function to call for each vector in the array |
|
arg |
Object
|
additional argument to pass to fn |
Optional |
Array
a
Creates a new vec4 initialized with values from an existing vector
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
vector to clone |
vec4
a new 4D vector
Creates a new vec4 initialized with the given values
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
|
w |
Number
|
W component |
vec4
a new 4D vector
Copy the values from one vec4 to another
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the source vector |
vec4
out
Set the components of a vec4 to the given values
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
|
w |
Number
|
W component |
vec4
out
Adds two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Subtracts vector b from vector a
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Multiplies two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Divides two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Math.ceil the components of a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to ceil |
vec4
out
Math.floor the components of a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to floor |
vec4
out
Returns the minimum of two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Returns the maximum of two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
vec4
out
Math.round the components of a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to round |
vec4
out
Scales a vec4 by a scalar number
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the vector to scale |
|
b |
Number
|
amount to scale the vector by |
vec4
out
Adds two vec4's after scaling the second operand by a scalar value
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 |
vec4
out
Calculates the euclidian distance between two vec4's
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
Number
distance between a and b
Calculates the squared euclidian distance between two vec4's
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
Number
squared distance between a and b
Calculates the length of a vec4
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
vector to calculate length of |
Number
length of a
Calculates the squared length of a vec4
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
vector to calculate squared length of |
Number
squared length of a
Negates the components of a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to negate |
vec4
out
Returns the inverse of the components of a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to invert |
vec4
out
Normalize a vec4
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
vector to normalize |
vec4
out
Calculates the dot product of two vec4's
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
Number
dot product of a and b
Returns the cross-product of three vectors in a 4-dimensional space
Name | Type | Description | |
---|---|---|---|
result |
vec4
|
the receiving vector |
|
U |
vec4
|
the first vector |
|
V |
vec4
|
the second vector |
|
W |
vec4
|
the third vector |
vec4
result
Performs a linear interpolation between two vec4's
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the first operand |
|
b |
vec4
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
vec4
out
Generates a random vector with the given scale
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
scale |
Number
|
Length of the resulting vector. If ommitted, a unit vector will be returned |
Optional |
vec4
out
Transforms the vec4 with a mat4.
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the vector to transform |
|
m |
mat4
|
matrix to transform with |
vec4
out
Transforms the vec4 with a quat
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
|
a |
vec4
|
the vector to transform |
|
q |
quat
|
quaternion to transform with |
vec4
out
Set the components of a vec4 to zero
Name | Type | Description | |
---|---|---|---|
out |
vec4
|
the receiving vector |
vec4
out
Returns a string representation of a vector
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
vector to represent as a string |
String
string representation of the vector
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
The first vector. |
|
b |
vec4
|
The second vector. |
Boolean
True if the vectors are equal, false otherwise.
Returns whether or not the vectors have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
vec4
|
The first vector. |
|
b |
vec4
|
The second vector. |
Boolean
True if the vectors are equal, false otherwise.
Perform some operation over an array of vec4s.
Name | Type | Description | |
---|---|---|---|
a |
Array
|
the array of vectors to iterate over |
|
stride |
Number
|
Number of elements between the start of each vec4. If 0 assumes tightly packed |
|
offset |
Number
|
Number of elements to skip at the beginning of the array |
|
count |
Number
|
Number of vec4s to iterate over. If 0 iterates over entire array |
|
fn |
Function
|
Function to call for each vector in the array |
|
arg |
Object
|
additional argument to pass to fn |
Optional |
Array
a
Set a quat to the identity quaternion
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
quat
out
Sets a quat from the given angle and rotation axis, then returns it.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
axis |
vec3
|
the axis around which to rotate |
|
rad |
Number
|
the angle in radians |
quat
out
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.
Name | Type | Description | |
---|---|---|---|
out_axis |
vec3
|
Vector receiving the axis of rotation |
|
q |
quat
|
Quaternion to be decomposed |
Number
Angle, in radians, of the rotation
Gets the angular distance between two unit quaternions
Name | Type | Description | |
---|---|---|---|
a |
quat
|
Origin unit quaternion |
|
b |
quat
|
Destination unit quaternion |
Number
Angle, in radians, between the two quaternions
Multiplies two quat's
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
quat
out
Rotates a quaternion by the given angle about the X axis
Name | Type | Description | |
---|---|---|---|
out |
quat
|
quat receiving operation result |
|
a |
quat
|
quat to rotate |
|
rad |
number
|
angle (in radians) to rotate |
quat
out
Rotates a quaternion by the given angle about the Y axis
Name | Type | Description | |
---|---|---|---|
out |
quat
|
quat receiving operation result |
|
a |
quat
|
quat to rotate |
|
rad |
number
|
angle (in radians) to rotate |
quat
out
Rotates a quaternion by the given angle about the Z axis
Name | Type | Description | |
---|---|---|---|
out |
quat
|
quat receiving operation result |
|
a |
quat
|
quat to rotate |
|
rad |
number
|
angle (in radians) to rotate |
quat
out
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.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate W component of |
quat
out
Calculate the exponential of a unit quaternion.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate the exponential of |
quat
out
Calculate the natural logarithm of a unit quaternion.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate the exponential of |
quat
out
Calculate the scalar power of a unit quaternion.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate the exponential of |
|
b |
Number
|
amount to scale the quaternion by |
quat
out
Performs a spherical linear interpolation between two quat
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
quat
out
Generates a random unit quaternion
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
quat
out
Calculates the inverse of a quat
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate inverse of |
quat
out
Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quat to calculate conjugate of |
quat
out
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.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
m |
mat3
|
rotation matrix |
quat
out
Creates a quaternion from the given euler angle x, y, z.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
Angle |
x
|
to rotate around X axis in degrees. |
|
Angle |
y
|
to rotate around Y axis in degrees. |
|
Angle |
z
|
to rotate around Z axis in degrees. |
quat
out
Returns a string representation of a quatenion
Name | Type | Description | |
---|---|---|---|
a |
quat
|
vector to represent as a string |
String
string representation of the vector
Creates a new quat initialized with values from an existing quaternion
Name | Type | Description | |
---|---|---|---|
a |
quat
|
quaternion to clone |
quat
a new quaternion
Creates a new quat initialized with the given values
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
|
w |
Number
|
W component |
quat
a new quaternion
Copy the values from one quat to another
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the source quaternion |
quat
out
Set the components of a quat to the given values
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
x |
Number
|
X component |
|
y |
Number
|
Y component |
|
z |
Number
|
Z component |
|
w |
Number
|
W component |
quat
out
Adds two quat's
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
quat
out
Scales a quat by a scalar number
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving vector |
|
a |
quat
|
the vector to scale |
|
b |
Number
|
amount to scale the vector by |
quat
out
Calculates the dot product of two quat's
Name | Type | Description | |
---|---|---|---|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
Number
dot product of a and b
Performs a linear interpolation between two quat's
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
quat
out
Calculates the length of a quat
Name | Type | Description | |
---|---|---|---|
a |
quat
|
vector to calculate length of |
Number
length of a
Calculates the squared length of a quat
Name | Type | Description | |
---|---|---|---|
a |
quat
|
vector to calculate squared length of |
Number
squared length of a
Normalize a quat
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
quaternion to normalize |
quat
out
Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
quat
|
The first quaternion. |
|
b |
quat
|
The second quaternion. |
Boolean
True if the vectors are equal, false otherwise.
Returns whether or not the quaternions have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
quat
|
The first vector. |
|
b |
quat
|
The second vector. |
Boolean
True if the vectors are equal, false otherwise.
Sets a quaternion to represent the shortest rotation from one vector to another.
Both vectors are assumed to be unit length.
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion. |
|
a |
vec3
|
the initial vector |
|
b |
vec3
|
the destination vector |
quat
out
Performs a spherical linear interpolation with two control points
Name | Type | Description | |
---|---|---|---|
out |
quat
|
the receiving quaternion |
|
a |
quat
|
the first operand |
|
b |
quat
|
the second operand |
|
c |
quat
|
the third operand |
|
d |
quat
|
the fourth operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
quat
out
Sets the specified quaternion with values corresponding to the given axes. Each axis is a vec3 and is expected to be unit length and perpendicular to all other specified axes.
Name | Type | Description | |
---|---|---|---|
view |
vec3
|
the vector representing the viewing direction |
|
right |
vec3
|
the vector representing the local "right" direction |
|
up |
vec3
|
the vector representing the local "up" direction |
quat
out
Creates a new identity dual quat
quat2
a new dual quaternion [real -> rotation, dual -> translation]
Creates a new quat initialized with values from an existing quaternion
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
dual quaternion to clone |
quat2
new dual quaternion
Creates a new dual quat initialized with the given values
Name | Type | Description | |
---|---|---|---|
x1 |
Number
|
X component |
|
y1 |
Number
|
Y component |
|
z1 |
Number
|
Z component |
|
w1 |
Number
|
W component |
|
x2 |
Number
|
X component |
|
y2 |
Number
|
Y component |
|
z2 |
Number
|
Z component |
|
w2 |
Number
|
W component |
quat2
new dual quaternion
Creates a new dual quat from the given values (quat and translation)
Name | Type | Description | |
---|---|---|---|
x1 |
Number
|
X component |
|
y1 |
Number
|
Y component |
|
z1 |
Number
|
Z component |
|
w1 |
Number
|
W component |
|
x2 |
Number
|
X component (translation) |
|
y2 |
Number
|
Y component (translation) |
|
z2 |
Number
|
Z component (translation) |
quat2
new dual quaternion
Creates a dual quat from a quaternion and a translation
Name | Type | Description | |
---|---|---|---|
dual |
quat2
|
quaternion receiving operation result |
|
q |
quat
|
a normalized quaternion |
|
t |
vec3
|
tranlation vector |
quat2
dual quaternion receiving operation result
Creates a dual quat from a translation
Name | Type | Description | |
---|---|---|---|
dual |
quat2
|
quaternion receiving operation result |
|
t |
vec3
|
translation vector |
quat2
dual quaternion receiving operation result
Creates a dual quat from a quaternion
Name | Type | Description | |
---|---|---|---|
dual |
quat2
|
quaternion receiving operation result |
|
q |
quat
|
the quaternion |
quat2
dual quaternion receiving operation result
Creates a new dual quat from a matrix (4x4)
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the dual quaternion |
|
a |
mat4
|
the matrix |
quat2
dual quat receiving operation result
Copy the values from one dual quat to another
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the source dual quaternion |
quat2
out
Set a dual quat to the identity dual quaternion
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving quaternion |
quat2
out
Set the components of a dual quat to the given values
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving quaternion |
|
x1 |
Number
|
X component |
|
y1 |
Number
|
Y component |
|
z1 |
Number
|
Z component |
|
w1 |
Number
|
W component |
|
x2 |
Number
|
X component |
|
y2 |
Number
|
Y component |
|
z2 |
Number
|
Z component |
|
w2 |
Number
|
W component |
quat2
out
Gets the real part of a dual quat
Name | Type | Description | |
---|---|---|---|
out |
quat
|
real part |
|
a |
quat2
|
Dual Quaternion |
quat
real part
Gets the dual part of a dual quat
Name | Type | Description | |
---|---|---|---|
out |
quat
|
dual part |
|
a |
quat2
|
Dual Quaternion |
quat
dual part
Set the real component of a dual quat to the given quaternion
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving quaternion |
|
q |
quat
|
a quaternion representing the real part |
quat2
out
Set the dual component of a dual quat to the given quaternion
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving quaternion |
|
q |
quat
|
a quaternion representing the dual part |
quat2
out
Gets the translation of a normalized dual quat
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
translation |
|
a |
quat2
|
Dual Quaternion to be decomposed |
vec3
translation
Translates a dual quat by the given vector
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to translate |
|
v |
vec3
|
vector to translate by |
quat2
out
Rotates a dual quat around the X axis
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to rotate |
|
rad |
number
|
how far should the rotation be |
quat2
out
Rotates a dual quat around the Y axis
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to rotate |
|
rad |
number
|
how far should the rotation be |
quat2
out
Rotates a dual quat around the Z axis
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to rotate |
|
rad |
number
|
how far should the rotation be |
quat2
out
Rotates a dual quat by a given quaternion (a * q)
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to rotate |
|
q |
quat
|
quaternion to rotate by |
quat2
out
Rotates a dual quat by a given quaternion (q * a)
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
q |
quat
|
quaternion to rotate by |
|
a |
quat2
|
the dual quaternion to rotate |
quat2
out
Rotates a dual quat around a given axis. Does the normalisation automatically
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the dual quaternion to rotate |
|
axis |
vec3
|
the axis to rotate around |
|
rad |
Number
|
how far the rotation should be |
quat2
out
Adds two dual quat's
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the first operand |
|
b |
quat2
|
the second operand |
quat2
out
Multiplies two dual quat's
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
the first operand |
|
b |
quat2
|
the second operand |
quat2
out
Scales a dual quat by a scalar number
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quat |
|
a |
quat2
|
the dual quat to scale |
|
b |
Number
|
amount to scale the dual quat by |
quat2
out
Calculates the dot product of two dual quat's (The dot product of the real parts)
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
the first operand |
|
b |
quat2
|
the second operand |
Number
dot product of a and b
Performs a linear interpolation between two dual quats's NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quat |
|
a |
quat2
|
the first operand |
|
b |
quat2
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
quat2
out
Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
dual quat to calculate inverse of |
quat2
out
Calculates the conjugate of a dual quat If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving quaternion |
|
a |
quat2
|
quat to calculate conjugate of |
quat2
out
Calculates the length of a dual quat
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
dual quat to calculate length of |
Number
length of a
Calculates the squared length of a dual quat
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
dual quat to calculate squared length of |
Number
squared length of a
Normalize a dual quat
Name | Type | Description | |
---|---|---|---|
out |
quat2
|
the receiving dual quaternion |
|
a |
quat2
|
dual quaternion to normalize |
quat2
out
Returns a string representation of a dual quatenion
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
dual quaternion to represent as a string |
String
string representation of the dual quat
Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
the first dual quaternion. |
|
b |
quat2
|
the second dual quaternion. |
Boolean
true if the dual quaternions are equal, false otherwise.
Returns whether or not the dual quaternions have approximately the same elements in the same position.
Name | Type | Description | |
---|---|---|---|
a |
quat2
|
the first dual quat. |
|
b |
quat2
|
the second dual quat. |
Boolean
true if the dual quats are equal, false otherwise.
Creates a new vec2 initialized with values from an existing vector
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
vector to clone |
vec2
a new 2D vector
Creates a new vec2 initialized with the given values
Name | Type | Description | |
---|---|---|---|
x |
Number
|
X component |
|
y |
Number
|
Y component |
vec2
a new 2D vector
Copy the values from one vec2 to another
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the source vector |
vec2
out
Set the components of a vec2 to the given values
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
x |
Number
|
X component |
|
y |
Number
|
Y component |
vec2
out
Adds two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Subtracts vector b from vector a
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Multiplies two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Divides two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Math.ceil the components of a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to ceil |
vec2
out
Math.floor the components of a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to floor |
vec2
out
Returns the minimum of two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Returns the maximum of two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec2
out
Math.round the components of a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to round |
vec2
out
Scales a vec2 by a scalar number
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the vector to scale |
|
b |
Number
|
amount to scale the vector by |
vec2
out
Adds two vec2's after scaling the second operand by a scalar value
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 |
vec2
out
Calculates the euclidian distance between two vec2's
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
Number
distance between a and b
Calculates the squared euclidian distance between two vec2's
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
Number
squared distance between a and b
Calculates the length of a vec2
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
vector to calculate length of |
Number
length of a
Calculates the squared length of a vec2
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
vector to calculate squared length of |
Number
squared length of a
Negates the components of a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to negate |
vec2
out
Returns the inverse of the components of a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to invert |
vec2
out
Normalize a vec2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
vector to normalize |
vec2
out
Calculates the dot product of two vec2's
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
Number
dot product of a and b
Computes the cross product of two vec2's Note that the cross product must by definition produce a 3D vector
Name | Type | Description | |
---|---|---|---|
out |
vec3
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
vec3
out
Performs a linear interpolation between two vec2's
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the first operand |
|
b |
vec2
|
the second operand |
|
t |
Number
|
interpolation amount, in the range [0-1], between the two inputs |
vec2
out
Generates a random vector with the given scale
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
scale |
Number
|
Length of the resulting vector. If ommitted, a unit vector will be returned |
Optional |
vec2
out
Transforms the vec2 with a mat2
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the vector to transform |
|
m |
mat2
|
matrix to transform with |
vec2
out
Transforms the vec2 with a mat2d
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the vector to transform |
|
m |
mat2d
|
matrix to transform with |
vec2
out
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the vector to transform |
|
m |
mat3
|
matrix to transform with |
vec2
out
Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
|
a |
vec2
|
the vector to transform |
|
m |
mat4
|
matrix to transform with |
vec2
out
Rotate a 2D vector
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
The receiving vec2 |
|
a |
vec2
|
The vec2 point to rotate |
|
b |
vec2
|
The origin of the rotation |
|
c |
Number
|
The angle of rotation |
vec2
out
Get the angle between two 2D vectors
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
The first operand |
|
b |
vec2
|
The second operand |
Number
The angle in radians
Set the components of a vec2 to zero
Name | Type | Description | |
---|---|---|---|
out |
vec2
|
the receiving vector |
vec2
out
Returns a string representation of a vector
Name | Type | Description | |
---|---|---|---|
a |
vec2
|
vector to represent as a string |