Back to Top

gl-matrix master

Javascript Matrix and Vector library for High Performance WebGL apps

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

Returns

Void

toRadian(a)

Convert Degree To Radian

Parameters

Name Type Description
a Number

Angle in Degrees

Returns

Void

equals(a, b)

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

Boolean

True if the numbers are approximately equal, false otherwise.

create()

Creates a new identity mat2

Returns

mat2

a new 2x2 matrix

clone(a)

Creates a new mat2 initialized with values from an existing matrix

Parameters

Name Type Description
a mat2

matrix to clone

Returns

mat2

a new 2x2 matrix

copy(out, a)

Copy the values from one mat2 to another

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the source matrix

Returns

mat2

out

identity(out)

Set a mat2 to the identity matrix

Parameters

Name Type Description
out mat2

the receiving matrix

Returns

mat2

out

fromValues(m00, m01, m10, m11)

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

mat2

out A new 2x2 matrix

set(out, m00, m01, m10, m11)

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

mat2

out

transpose(out, a)

Transpose the values of a mat2

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the source matrix

Returns

mat2

out

invert(out, a)

Inverts a mat2

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the source matrix

Returns

mat2

out

adjoint(out, a)

Calculates the adjugate of a mat2

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the source matrix

Returns

mat2

out

determinant(a)

Calculates the determinant of a mat2

Parameters

Name Type Description
a mat2

the source matrix

Returns

Number

determinant of a

multiply(out, a, b)

Multiplies two mat2's

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the first operand

b mat2

the second operand

Returns

mat2

out

rotate(out, a, rad)

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

mat2

out

scale(out, a, v)

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

mat2

out

fromRotation(out, rad)

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

mat2

out

fromScaling(out, v)

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

mat2

out

str(a)

Returns a string representation of a mat2

Parameters

Name Type Description
a mat2

matrix to represent as a string

Returns

String

string representation of the matrix

frob(a)

Returns Frobenius norm of a mat2

Parameters

Name Type Description
a mat2

the matrix to calculate Frobenius norm of

Returns

Number

Frobenius norm

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

Returns

Void

add(out, a, b)

Adds two mat2's

Parameters

Name Type Description
out mat2

the receiving matrix

a mat2

the first operand

b mat2

the second operand

Returns

mat2

out

subtract(out, a, b)

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

mat2

out

exactEquals(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

equals$1(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

multiplyScalar(out, a, b)

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

mat2

out

multiplyScalarAndAdd(out, a, b, scale)

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

mat2

out

mul()

Alias for {@link mat2.multiply}

Returns

Void

sub()

Alias for {@link mat2.subtract}

Returns

Void

create$1()

Creates a new identity mat2d

Returns

mat2d

a new 2x3 matrix

clone$1(a)

Creates a new mat2d initialized with values from an existing matrix

Parameters

Name Type Description
a mat2d

matrix to clone

Returns

mat2d

a new 2x3 matrix

copy$1(out, a)

Copy the values from one mat2d to another

Parameters

Name Type Description
out mat2d

the receiving matrix

a mat2d

the source matrix

Returns

mat2d

out

identity$1(out)

Set a mat2d to the identity matrix

Parameters

Name Type Description
out mat2d

the receiving matrix

Returns

mat2d

out

fromValues$1(a, b, c, d, tx, ty)

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

mat2d

A new mat2d

set$1(out, a, b, c, d, tx, ty)

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

mat2d

out

invert$1(out, a)

Inverts a mat2d

Parameters

Name Type Description
out mat2d

the receiving matrix

a mat2d

the source matrix

Returns

mat2d

out

determinant$1(a)

Calculates the determinant of a mat2d

Parameters

Name Type Description
a mat2d

the source matrix

Returns

Number

determinant of a

multiply$1(out, a, b)

Multiplies two mat2d's

Parameters

Name Type Description
out mat2d

the receiving matrix

a mat2d

the first operand

b mat2d

the second operand

Returns

mat2d

out

rotate$1(out, a, rad)

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

mat2d

out

scale$1(out, a, v)

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

mat2d

out

translate(out, a, v)

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

mat2d

out

fromRotation$1(out, rad)

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

mat2d

out

fromScaling$1(out, v)

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

mat2d

out

fromTranslation(out, v)

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

mat2d

out

str$1(a)

Returns a string representation of a mat2d

Parameters

Name Type Description
a mat2d

matrix to represent as a string

Returns

String

string representation of the matrix

frob$1(a)

Returns Frobenius norm of a mat2d

Parameters

Name Type Description
a mat2d

the matrix to calculate Frobenius norm of

Returns

Number

Frobenius norm

add$1(out, a, b)

Adds two mat2d's

Parameters

Name Type Description
out mat2d

the receiving matrix

a mat2d

the first operand

b mat2d

the second operand

Returns

mat2d

out

subtract$1(out, a, b)

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

mat2d

out

multiplyScalar$1(out, a, b)

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

mat2d

out

multiplyScalarAndAdd$1(out, a, b, scale)

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

mat2d

out

exactEquals$1(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

equals$2(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

mul$1()

Alias for {@link mat2d.multiply}

Returns

Void

sub$1()

Alias for {@link mat2d.subtract}

Returns

Void

create$2()

Creates a new identity mat3

Returns

mat3

a new 3x3 matrix

fromMat4(out, a)

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

mat3

out

clone$2(a)

Creates a new mat3 initialized with values from an existing matrix

Parameters

Name Type Description
a mat3

matrix to clone

Returns

mat3

a new 3x3 matrix

copy$2(out, a)

Copy the values from one mat3 to another

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the source matrix

Returns

mat3

out

fromValues$2(m00, m01, m02, m10, m11, m12, m20, m21, m22)

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

mat3

A new mat3

set$2(out, m00, m01, m02, m10, m11, m12, m20, m21, m22)

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

mat3

out

identity$2(out)

Set a mat3 to the identity matrix

Parameters

Name Type Description
out mat3

the receiving matrix

Returns

mat3

out

transpose$1(out, a)

Transpose the values of a mat3

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the source matrix

Returns

mat3

out

invert$2(out, a)

Inverts a mat3

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the source matrix

Returns

mat3

out

adjoint$1(out, a)

Calculates the adjugate of a mat3

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the source matrix

Returns

mat3

out

determinant$2(a)

Calculates the determinant of a mat3

Parameters

Name Type Description
a mat3

the source matrix

Returns

Number

determinant of a

multiply$2(out, a, b)

Multiplies two mat3's

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the first operand

b mat3

the second operand

Returns

mat3

out

translate$1(out, a, v)

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

mat3

out

rotate$2(out, a, rad)

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

mat3

out

scale$2(out, a, v)

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

mat3

out

fromTranslation$1(out, v)

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

mat3

out

fromRotation$2(out, rad)

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

mat3

out

fromScaling$2(out, v)

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

mat3

out

fromMat2d(out, a)

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

mat3

out

fromQuat(out, q)

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

mat3

out

normalFromMat4(out, a)

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

mat3

out

projection(out, width, height)

Generates a 2D projection matrix with the given bounds

Parameters

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

Returns

mat3

out

str$2(a)

Returns a string representation of a mat3

Parameters

Name Type Description
a mat3

matrix to represent as a string

Returns

String

string representation of the matrix

frob$2(a)

Returns Frobenius norm of a mat3

Parameters

Name Type Description
a mat3

the matrix to calculate Frobenius norm of

Returns

Number

Frobenius norm

add$2(out, a, b)

Adds two mat3's

Parameters

Name Type Description
out mat3

the receiving matrix

a mat3

the first operand

b mat3

the second operand

Returns

mat3

out

subtract$2(out, a, b)

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

mat3

out

multiplyScalar$2(out, a, b)

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

mat3

out

multiplyScalarAndAdd$2(out, a, b, scale)

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

mat3

out

exactEquals$2(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

equals$3(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

mul$2()

Alias for {@link mat3.multiply}

Returns

Void

sub$2()

Alias for {@link mat3.subtract}

Returns

Void

create$3()

Creates a new identity mat4

Returns

mat4

a new 4x4 matrix

clone$3(a)

Creates a new mat4 initialized with values from an existing matrix

Parameters

Name Type Description
a mat4

matrix to clone

Returns

mat4

a new 4x4 matrix

copy$3(out, a)

Copy the values from one mat4 to another

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the source matrix

Returns

mat4

out

fromValues$3(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

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

mat4

A new mat4

set$3(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

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

mat4

out

identity$3(out)

Set a mat4 to the identity matrix

Parameters

Name Type Description
out mat4

the receiving matrix

Returns

mat4

out

transpose$2(out, a)

Transpose the values of a mat4

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the source matrix

Returns

mat4

out

invert$3(out, a)

Inverts a mat4

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the source matrix

Returns

mat4

out

adjoint$2(out, a)

Calculates the adjugate of a mat4

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the source matrix

Returns

mat4

out

determinant$3(a)

Calculates the determinant of a mat4

Parameters

Name Type Description
a mat4

the source matrix

Returns

Number

determinant of a

multiply$3(out, a, b)

Multiplies two mat4s

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the first operand

b mat4

the second operand

Returns

mat4

out

translate$2(out, a, v)

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

mat4

out

scale$3(out, a, v)

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

mat4

out

rotate$3(out, a, rad, axis)

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

mat4

out

rotateX(out, a, rad)

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

mat4

out

rotateY(out, a, rad)

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

mat4

out

rotateZ(out, a, rad)

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

mat4

out

fromTranslation$2(out, v)

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

mat4

out

fromScaling$3(out, v)

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

mat4

out

fromRotation$3(out, rad, axis)

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

mat4

out

fromXRotation(out, rad)

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

mat4

out

fromYRotation(out, rad)

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

mat4

out

fromZRotation(out, rad)

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

mat4

out

fromRotationTranslation(out, q, v)

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

mat4

out

fromQuat2(out, a)

Creates a new mat4 from a dual quat.

Parameters

Name Type Description
out mat4

Matrix

a quat2

Dual Quaternion

Returns

mat4

mat4 receiving operation result

getTranslation(out, mat)

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

vec3

out

getScaling(out, mat)

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

vec3

out

getRotation(out, mat)

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

quat

out

fromRotationTranslationScale(out, q, v, s)

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

mat4

out

fromRotationTranslationScaleOrigin(out, q, v, s, o)

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

mat4

out

fromQuat$1(out, q)

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

mat4

out

frustum(out, left, right, bottom, top, near, far)

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

mat4

out

perspective(out, fovy, aspect, near, far)

Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.

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, can be null or Infinity

Returns

mat4

out

perspectiveFromFieldOfView(out, fov, near, far)

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

mat4

out

ortho(out, left, right, bottom, top, near, far)

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

mat4

out

lookAt(out, eye, center, up)

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.

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

mat4

out

targetTo(out, eye, center, up)

Generates a matrix that makes something look at something else.

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

mat4

out

str$3(a)

Returns a string representation of a mat4

Parameters

Name Type Description
a mat4

matrix to represent as a string

Returns

String

string representation of the matrix

frob$3(a)

Returns Frobenius norm of a mat4

Parameters

Name Type Description
a mat4

the matrix to calculate Frobenius norm of

Returns

Number

Frobenius norm

add$3(out, a, b)

Adds two mat4's

Parameters

Name Type Description
out mat4

the receiving matrix

a mat4

the first operand

b mat4

the second operand

Returns

mat4

out

subtract$3(out, a, b)

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

mat4

out

multiplyScalar$3(out, a, b)

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

mat4

out

multiplyScalarAndAdd$3(out, a, b, scale)

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

mat4

out

exactEquals$3(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

equals$4(a, b)

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

Boolean

True if the matrices are equal, false otherwise.

mul$3()

Alias for {@link mat4.multiply}

Returns

Void

sub$3()

Alias for {@link mat4.subtract}

Returns

Void

create$4()

Creates a new, empty vec3

Returns

vec3

a new 3D vector

clone$4(a)

Creates a new vec3 initialized with values from an existing vector

Parameters

Name Type Description
a vec3

vector to clone

Returns

vec3

a new 3D vector

length(a)

Calculates the length of a vec3

Parameters

Name Type Description
a vec3

vector to calculate length of

Returns

Number

length of a

fromValues$4(x, y, z)

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

vec3

a new 3D vector

copy$4(out, a)

Copy the values from one vec3 to another

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the source vector

Returns

vec3

out

set$4(out, x, y, z)

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

vec3

out

add$4(out, a, b)

Adds two vec3's

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns

vec3

out

subtract$4(out, a, b)

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

vec3

out

multiply$4(out, a, b)

Multiplies two vec3's

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns

vec3

out

divide(out, a, b)

Divides two vec3's

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns

vec3

out

ceil(out, a)

Math.ceil the components of a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to ceil

Returns

vec3

out

floor(out, a)

Math.floor the components of a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to floor

Returns

vec3

out

min(out, a, b)

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

vec3

out

max(out, a, b)

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

vec3

out

round(out, a)

Math.round the components of a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to round

Returns

vec3

out

scale$4(out, a, b)

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

vec3

out

scaleAndAdd(out, a, b, scale)

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

vec3

out

distance(a, b)

Calculates the euclidian distance between two vec3's

Parameters

Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns

Number

distance between a and b

squaredDistance(a, b)

Calculates the squared euclidian distance between two vec3's

Parameters

Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns

Number

squared distance between a and b

squaredLength(a)

Calculates the squared length of a vec3

Parameters

Name Type Description
a vec3

vector to calculate squared length of

Returns

Number

squared length of a

negate(out, a)

Negates the components of a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to negate

Returns

vec3

out

inverse(out, a)

Returns the inverse of the components of a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to invert

Returns

vec3

out

normalize(out, a)

Normalize a vec3

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

vector to normalize

Returns

vec3

out

dot(a, b)

Calculates the dot product of two vec3's

Parameters

Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns

Number

dot product of a and b

cross(out, a, b)

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

vec3

out

lerp(out, a, b, t)

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, in the range [0-1], between the two inputs

Returns

vec3

out

hermite(out, a, b, c, d, t)

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, in the range [0-1], between the two inputs

Returns

vec3

out

bezier(out, a, b, c, d, t)

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, in the range [0-1], between the two inputs

Returns

vec3

out

random(out[, scale])

Generates a random vector with the given scale

Parameters

Name Type Description
out vec3

the receiving vector

scale Number

Length of the resulting vector. If ommitted, a unit vector will be returned

Optional

Returns

vec3

out

transformMat4(out, a, m)

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

vec3

out

transformMat3(out, a, m)

Transforms the vec3 with a mat3.

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the vector to transform

m mat3

the 3x3 matrix to transform with

Returns

vec3

out

transformQuat(out, a, q)

Transforms the vec3 with a quat Can also be used for dual quaternions. (Multiply it with the real part)

Parameters

Name Type Description
out vec3

the receiving vector

a vec3

the vector to transform

q quat

quaternion to transform with

Returns

vec3

out

rotateX$1(out, a, b, c)

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

vec3

out

rotateY$1(out, a, b, c)

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

vec3

out

rotateZ$1(out, a, b, c)

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

vec3

out

angle(a, b)

Get the angle between two 3D vectors

Parameters

Name Type Description
a vec3

The first operand

b vec3

The second operand

Returns

Number

The angle in radians

str$4(a)

Returns a string representation of a vector

Parameters

Name Type Description
a vec3

vector to represent as a string

Returns

String

string representation of the vector

exactEquals$4(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

equals$5(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

sub$4()

Alias for {@link vec3.subtract}

Returns

Void

mul$4()

Alias for {@link vec3.multiply}

Returns

Void

div()

Alias for {@link vec3.divide}

Returns

Void

dist()

Alias for {@link vec3.distance}

Returns

Void

sqrDist()

Alias for {@link vec3.squaredDistance}

Returns

Void

len()

Alias for {@link vec3.length}

Returns

Void

sqrLen()

Alias for {@link vec3.squaredLength}

Returns

Void

forEach(a, stride, offset, count, fn[, arg])

Perform some operation over an array of vec3s.

Parameters

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

Returns

Array

a

create$5()

Creates a new, empty vec4

Returns

vec4

a new 4D vector

clone$5(a)

Creates a new vec4 initialized with values from an existing vector

Parameters

Name Type Description
a vec4

vector to clone

Returns

vec4

a new 4D vector

fromValues$5(x, y, z, w)

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

vec4

a new 4D vector

copy$5(out, a)

Copy the values from one vec4 to another

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

the source vector

Returns

vec4

out

set$5(out, x, y, z, w)

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

vec4

out

add$5(out, a, b)

Adds two vec4's

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

the first operand

b vec4

the second operand

Returns

vec4

out

subtract$5(out, a, b)

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

vec4

out

multiply$5(out, a, b)

Multiplies two vec4's

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

the first operand

b vec4

the second operand

Returns

vec4

out

divide$1(out, a, b)

Divides two vec4's

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

the first operand

b vec4

the second operand

Returns

vec4

out

ceil$1(out, a)

Math.ceil the components of a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to ceil

Returns

vec4

out

floor$1(out, a)

Math.floor the components of a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to floor

Returns

vec4

out

min$1(out, a, b)

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

vec4

out

max$1(out, a, b)

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

vec4

out

round$1(out, a)

Math.round the components of a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to round

Returns

vec4

out

scale$5(out, a, b)

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

vec4

out

scaleAndAdd$1(out, a, b, scale)

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

vec4

out

distance$1(a, b)

Calculates the euclidian distance between two vec4's

Parameters

Name Type Description
a vec4

the first operand

b vec4

the second operand

Returns

Number

distance between a and b

squaredDistance$1(a, b)

Calculates the squared euclidian distance between two vec4's

Parameters

Name Type Description
a vec4

the first operand

b vec4

the second operand

Returns

Number

squared distance between a and b

length$1(a)

Calculates the length of a vec4

Parameters

Name Type Description
a vec4

vector to calculate length of

Returns

Number

length of a

squaredLength$1(a)

Calculates the squared length of a vec4

Parameters

Name Type Description
a vec4

vector to calculate squared length of

Returns

Number

squared length of a

negate$1(out, a)

Negates the components of a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to negate

Returns

vec4

out

inverse$1(out, a)

Returns the inverse of the components of a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to invert

Returns

vec4

out

normalize$1(out, a)

Normalize a vec4

Parameters

Name Type Description
out vec4

the receiving vector

a vec4

vector to normalize

Returns

vec4

out

dot$1(a, b)

Calculates the dot product of two vec4's

Parameters

Name Type Description
a vec4

the first operand

b vec4

the second operand

Returns

Number

dot product of a and b

lerp$1(out, a, b, t)

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, in the range [0-1], between the two inputs

Returns

vec4

out

random$1(out[, scale])

Generates a random vector with the given scale

Parameters

Name Type Description
out vec4

the receiving vector

scale Number

Length of the resulting vector. If ommitted, a unit vector will be returned

Optional

Returns

vec4

out

transformMat4$1(out, a, m)

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

vec4

out

transformQuat$1(out, a, q)

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

vec4

out

str$5(a)

Returns a string representation of a vector

Parameters

Name Type Description
a vec4

vector to represent as a string

Returns

String

string representation of the vector

exactEquals$5(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

equals$6(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

sub$5()

Alias for {@link vec4.subtract}

Returns

Void

mul$5()

Alias for {@link vec4.multiply}

Returns

Void

div$1()

Alias for {@link vec4.divide}

Returns

Void

dist$1()

Alias for {@link vec4.distance}

Returns

Void

sqrDist$1()

Alias for {@link vec4.squaredDistance}

Returns

Void

len$1()

Alias for {@link vec4.length}

Returns

Void

sqrLen$1()

Alias for {@link vec4.squaredLength}

Returns

Void

forEach$1(a, stride, offset, count, fn[, arg])

Perform some operation over an array of vec4s.

Parameters

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

Returns

Array

a

create$6()

Creates a new identity quat

Returns

quat

a new quaternion

identity$4(out)

Set a quat to the identity quaternion

Parameters

Name Type Description
out quat

the receiving quaternion

Returns

quat

out

setAxisAngle(out, axis, rad)

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

quat

out

getAxisAngle(out_axis, q)

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

Number

Angle, in radians, of the rotation

multiply$6(out, a, b)

Multiplies two quat's

Parameters

Name Type Description
out quat

the receiving quaternion

a quat

the first operand

b quat

the second operand

Returns

quat

out

rotateX$2(out, a, rad)

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

quat

out

rotateY$2(out, a, rad)

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

quat

out

rotateZ$2(out, a, rad)

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

quat

out

calculateW(out, a)

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

quat

out

slerp(out, a, b, t)

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, in the range [0-1], between the two inputs

Returns

quat

out

random$2(out)

Generates a random quaternion

Parameters

Name Type Description
out quat

the receiving quaternion

Returns

quat

out

invert$4(out, a)

Calculates the inverse of a quat

Parameters

Name Type Description
out quat

the receiving quaternion

a quat

quat to calculate inverse of

Returns

quat

out

conjugate(out, a)

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

quat

out

fromMat3(out, m)

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

quat

out

fromEuler(out, Angle, Angle, Angle)

Creates a quaternion from the given euler angle x, y, z.

Parameters

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.

Returns

quat

out

str$6(a)

Returns a string representation of a quatenion

Parameters

Name Type Description
a quat

vector to represent as a string

Returns

String

string representation of the vector

clone$6(a)

Creates a new quat initialized with values from an existing quaternion

Parameters

Name Type Description
a quat

quaternion to clone

Returns

quat

a new quaternion

fromValues$6(x, y, z, w)

Creates a new quat 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

quat

a new quaternion

copy$6(out, a)

Copy the values from one quat to another

Parameters

Name Type Description
out quat

the receiving quaternion

a quat

the source quaternion

Returns

quat

out

set$6(out, x, y, z, w)

Set the components of a quat to the given values

Parameters

Name Type Description
out quat

the receiving quaternion

x Number

X component

y Number

Y component

z Number

Z component

w Number

W component

Returns

quat

out

add$6(out, a, b)

Adds two quat's

Parameters

Name Type Description
out quat

the receiving quaternion

a quat

the first operand

b quat

the second operand

Returns

quat

out

mul$6()

Alias for {@link quat.multiply}

Returns

Void

scale$6(out, a, b)

Scales a quat by a scalar number

Parameters

Name Type Description
out quat

the receiving vector

a quat

the vector to scale

b Number

amount to scale the vector by

Returns

quat

out

dot$2(a, b)

Calculates the dot product of two quat's

Parameters

Name Type Description
a quat

the first operand

b quat

the second operand

Returns

Number

dot product of a and b

lerp$2(out, a, b, t)

Performs a linear interpolation between two quat's

Parameters

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

Returns

quat

out

length$2(a)

Calculates the length of a quat

Parameters

Name Type Description
a quat

vector to calculate length of

Returns

Number

length of a

len$2()

Alias for {@link quat.length}

Returns

Void

squaredLength$2(a)

Calculates the squared length of a quat

Parameters

Name Type Description
a quat

vector to calculate squared length of

Returns

Number

squared length of a

sqrLen$2()

Alias for {@link quat.squaredLength}

Returns

Void

normalize$2(out, a)

Normalize a quat

Parameters

Name Type Description
out quat

the receiving quaternion

a quat

quaternion to normalize

Returns

quat

out

exactEquals$6(a, b)

Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)

Parameters

Name Type Description
a quat

The first quaternion.

b quat

The second quaternion.

Returns

Boolean

True if the vectors are equal, false otherwise.

equals$7(a, b)

Returns whether or not the quaternions have approximately the same elements in the same position.

Parameters

Name Type Description
a quat

The first vector.

b quat

The second vector.

Returns

Boolean

True if the vectors are equal, false otherwise.

rotationTo(out, a, b)

Sets a quaternion to represent the shortest rotation from one vector to another.

Both vectors are assumed to be unit length.

Parameters

Name Type Description
out quat

the receiving quaternion.

a vec3

the initial vector

b vec3

the destination vector

Returns

quat

out

sqlerp(out, a, b, c, d, t)

Performs a spherical linear interpolation with two control points

Parameters

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

Returns

quat

out

setAxes(view, right, up)

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.

Parameters

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

Returns

quat

out

create$7()

Creates a new identity dual quat

Returns

quat2

a new dual quaternion [real -> rotation, dual -> translation]

clone$7(a)

Creates a new quat initialized with values from an existing quaternion

Parameters

Name Type Description
a quat2

dual quaternion to clone

Returns

quat2

new dual quaternion

fromValues$7(x1, y1, z1, w1, x2, y2, z2, w2)

Creates a new dual quat initialized with the given values

Parameters

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

Returns

quat2

new dual quaternion

fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2)

Creates a new dual quat from the given values (quat and translation)

Parameters

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)

Returns

quat2

new dual quaternion

fromRotationTranslation$1(dual, q, t)

Creates a dual quat from a quaternion and a translation

Parameters

Name Type Description
dual quat2

quaternion receiving operation result

q quat

quaternion

t vec3

tranlation vector

Returns

quat2

dual quaternion receiving operation result

fromTranslation$3(dual, t)

Creates a dual quat from a translation

Parameters

Name Type Description
dual quat2

quaternion receiving operation result

t vec3

translation vector

Returns

quat2

dual quaternion receiving operation result

fromRotation$4(dual, q)

Creates a dual quat from a quaternion

Parameters

Name Type Description
dual quat2

quaternion receiving operation result

q quat

the quaternion

Returns

quat2

dual quaternion receiving operation result

fromMat4$1(out, a)

Creates a new dual quat from a matrix (4x4)

Parameters

Name Type Description
out quat2

the dual quaternion

a mat4

the matrix

Returns

quat2

dual quat receiving operation result

copy$7(out, a)

Copy the values from one dual quat to another

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the source dual quaternion

Returns

quat2

out

identity$5(out)

Set a dual quat to the identity dual quaternion

Parameters

Name Type Description
out quat2

the receiving quaternion

Returns

quat2

out

set$7(out, x1, y1, z1, w1, x2, y2, z2, w2)

Set the components of a dual quat to the given values

Parameters

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

Returns

quat2

out

getReal(out, a)

Gets the real part of a dual quat

Parameters

Name Type Description
out quat

real part

a quat2

Dual Quaternion

Returns

quat

real part

getDual(out, a)

Gets the dual part of a dual quat

Parameters

Name Type Description
out quat

dual part

a quat2

Dual Quaternion

Returns

quat

dual part

setReal(out, q)

Set the real component of a dual quat to the given quaternion

Parameters

Name Type Description
out quat2

the receiving quaternion

q quat

a quaternion representing the real part

Returns

quat2

out

setDual(out, q)

Set the dual component of a dual quat to the given quaternion

Parameters

Name Type Description
out quat2

the receiving quaternion

q quat

a quaternion representing the dual part

Returns

quat2

out

getTranslation$1(out, a)

Gets the translation of a normalized dual quat

Parameters

Name Type Description
out vec3

translation

a quat2

Dual Quaternion to be decomposed

Returns

vec3

translation

translate$3(out, a, v)

Translates a dual quat by the given vector

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the dual quaternion to translate

v vec3

vector to translate by

Returns

quat2

out

rotateX$3(out, a, rad)

Rotates a dual quat around the X axis

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the dual quaternion to rotate

rad number

how far should the rotation be

Returns

quat2

out

rotateY$3(out, a, rad)

Rotates a dual quat around the Y axis

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the dual quaternion to rotate

rad number

how far should the rotation be

Returns

quat2

out

rotateZ$3(out, a, rad)

Rotates a dual quat around the Z axis

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the dual quaternion to rotate

rad number

how far should the rotation be

Returns

quat2

out

rotateByQuatAppend(out, a, q)

Rotates a dual quat by a given quaternion (a * q)

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the dual quaternion to rotate

q quat

quaternion to rotate by

Returns

quat2

out

rotateByQuatPrepend(out, q, a)

Rotates a dual quat by a given quaternion (q * a)

Parameters

Name Type Description
out quat2

the receiving dual quaternion

q quat

quaternion to rotate by

a quat2

the dual quaternion to rotate

Returns

quat2

out

rotateAroundAxis(out, a, axis, rad)

Rotates a dual quat around a given axis. Does the normalisation automatically

Parameters

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

Returns

quat2

out

add$7(out, a, b)

Adds two dual quat's

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the first operand

b quat2

the second operand

Returns

quat2

out

multiply$7(out, a, b)

Multiplies two dual quat's

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

the first operand

b quat2

the second operand

Returns

quat2

out

mul$7()

Alias for {@link quat2.multiply}

Returns

Void

scale$7(out, a, b)

Scales a dual quat by a scalar number

Parameters

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

Returns

quat2

out

dot$3(a, b)

Calculates the dot product of two dual quat's (The dot product of the real parts)

Parameters

Name Type Description
a quat2

the first operand

b quat2

the second operand

Returns

Number

dot product of a and b

lerp$3(out, a, b, t)

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)

Parameters

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

Returns

quat2

out

invert$5(out, a)

Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

dual quat to calculate inverse of

Returns

quat2

out

conjugate$1(out, a)

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.

Parameters

Name Type Description
out quat2

the receiving quaternion

a quat2

quat to calculate conjugate of

Returns

quat2

out

length$3(a)

Calculates the length of a dual quat

Parameters

Name Type Description
a quat2

dual quat to calculate length of

Returns

Number

length of a

len$3()

Alias for {@link quat2.length}

Returns

Void

squaredLength$3(a)

Calculates the squared length of a dual quat

Parameters

Name Type Description
a quat2

dual quat to calculate squared length of

Returns

Number

squared length of a

sqrLen$3()

Alias for {@link quat2.squaredLength}

Returns

Void

normalize$3(out, a)

Normalize a dual quat

Parameters

Name Type Description
out quat2

the receiving dual quaternion

a quat2

dual quaternion to normalize

Returns

quat2

out

str$7(a)

Returns a string representation of a dual quatenion

Parameters

Name Type Description
a quat2

dual quaternion to represent as a string

Returns

String

string representation of the dual quat

exactEquals$7(a, b)

Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)

Parameters

Name Type Description
a quat2

the first dual quaternion.

b quat2

the second dual quaternion.

Returns

Boolean

true if the dual quaternions are equal, false otherwise.

equals$8(a, b)

Returns whether or not the dual quaternions have approximately the same elements in the same position.

Parameters

Name Type Description
a quat2

the first dual quat.

b quat2

the second dual quat.

Returns

Boolean

true if the dual quats are equal, false otherwise.

create$8()

Creates a new, empty vec2

Returns

vec2

a new 2D vector

clone$8(a)

Creates a new vec2 initialized with values from an existing vector

Parameters

Name Type Description
a vec2

vector to clone

Returns

vec2

a new 2D vector

fromValues$8(x, y)

Creates a new vec2 initialized with the given values

Parameters

Name Type Description
x Number

X component

y Number

Y component

Returns

vec2

a new 2D vector

copy$8(out, a)

Copy the values from one vec2 to another

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

the source vector

Returns

vec2

out

set$8(out, x, y)

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

vec2

out

add$8(out, a, b)

Adds two vec2's

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

the first operand

b vec2

the second operand

Returns

vec2

out

subtract$6(out, a, b)

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

vec2

out

multiply$8(out, a, b)

Multiplies two vec2's

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

the first operand

b vec2

the second operand

Returns

vec2

out

divide$2(out, a, b)

Divides two vec2's

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

the first operand

b vec2

the second operand

Returns

vec2

out

ceil$2(out, a)

Math.ceil the components of a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to ceil

Returns

vec2

out

floor$2(out, a)

Math.floor the components of a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to floor

Returns

vec2

out

min$2(out, a, b)

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

vec2

out

max$2(out, a, b)

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

vec2

out

round$2(out, a)

Math.round the components of a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to round

Returns

vec2

out

scale$8(out, a, b)

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

vec2

out

scaleAndAdd$2(out, a, b, scale)

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

vec2

out

distance$2(a, b)

Calculates the euclidian distance between two vec2's

Parameters

Name Type Description
a vec2

the first operand

b vec2

the second operand

Returns

Number

distance between a and b

squaredDistance$2(a, b)

Calculates the squared euclidian distance between two vec2's

Parameters

Name Type Description
a vec2

the first operand

b vec2

the second operand

Returns

Number

squared distance between a and b

length$4(a)

Calculates the length of a vec2

Parameters

Name Type Description
a vec2

vector to calculate length of

Returns

Number

length of a

squaredLength$4(a)

Calculates the squared length of a vec2

Parameters

Name Type Description
a vec2

vector to calculate squared length of

Returns

Number

squared length of a

negate$2(out, a)

Negates the components of a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to negate

Returns

vec2

out

inverse$2(out, a)

Returns the inverse of the components of a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to invert

Returns

vec2

out

normalize$4(out, a)

Normalize a vec2

Parameters

Name Type Description
out vec2

the receiving vector

a vec2

vector to normalize

Returns

vec2

out

dot$4(a, b)

Calculates the dot product of two vec2's

Parameters

Name Type Description
a vec2

the first operand

b vec2

the second operand

Returns

Number

dot product of a and b

cross$1(out, a, b)

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

vec3

out

lerp$4(out, a, b, t)

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, in the range [0-1], between the two inputs

Returns

vec2

out

random$3(out[, scale])

Generates a random vector with the given scale

Parameters

Name Type Description
out vec2

the receiving vector

scale Number

Length of the resulting vector. If ommitted, a unit vector will be returned

Optional

Returns

vec2

out

transformMat2(out, a, m)

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

vec2

out

transformMat2d(out, a, m)

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

vec2

out

transformMat3$1(out, a, m)

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

vec2

out

transformMat4$2(out, a, m)

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

vec2

out

rotate$4(out, a, b, c)

Rotate a 2D vector

Parameters

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

Returns

vec2

out

angle$1(a, b)

Get the angle between two 2D vectors

Parameters

Name Type Description
a vec2

The first operand

b vec2

The second operand

Returns

Number

The angle in radians

str$8(a)

Returns a string representation of a vector

Parameters

Name Type Description
a vec2

vector to represent as a string

Returns

String

string representation of the vector

exactEquals$8(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

equals$9(a, b)

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

Boolean

True if the vectors are equal, false otherwise.

len$4()

Alias for {@link vec2.length}

Returns

Void

sub$6()

Alias for {@link vec2.subtract}

Returns

Void

mul$8()

Alias for {@link vec2.multiply}

Returns

Void

div$2()

Alias for {@link vec2.divide}

Returns

Void

dist$2()

Alias for {@link vec2.distance}

Returns

Void

sqrDist$2()

Alias for {@link vec2.squaredDistance}

Returns

Void

sqrLen$4()

Alias for {@link vec2.squaredLength}

Returns

Void

forEach$2(a, stride, offset, count, fn[, arg])

Perform some operation over an array of vec2s.

Parameters

Name Type Description
a Array

the array of vectors to iterate over

stride Number

Number of elements between the start of each vec2. If 0 assumes tightly packed

offset Number

Number of elements to skip at the beginning of the array

count Number

Number of vec2s 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

Returns

Array

a

publish()

Called automatically by JsDoc Toolkit.

Returns

Void

summarize()

Just the first sentence (up to a full stop). Should not break on dotted variable names.

Returns

Void

makeSortby()

Make a symbol sorter by some attribute.

Returns

Void

include()

Pull in the contents of an external file at the given path.

Returns

Void

makeSrcFile()

Turn a raw source file into a code-hilited page in the docs.

Returns

Void

makeSignature()

Build output for displaying function parameters.

Returns

Void

Find symbol {@link ...} strings in text and turn into html links

Returns

Void

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

Returns

Void

toRadian(a)

Convert Degree To Radian

Parameters

Name Type Descript