- EPSILON
- equals
- approx
- clamp
- clamp01
- lerp
- toRadian
- toDegree
- random
- randomRange
- randomRangeInt
- vec2
- create
- new
- clone
- copy
- set
- add
- subtract
- sub
- multiply
- mul
- divide
- div
- ceil
- floor
- min
- max
- round
- scale
- scaleAndAdd
- distance
- dist
- squaredDistance
- sqrDist
- length
- len
- squaredLength
- sqrLen
- negate
- inverse
- inverseSafe
- normalize
- dot
- cross
- lerp
- random
- transformMat2
- transformMat23
- transformMat3
- transformMat4
- forEach
- str
- array
- exactEquals
- equals
- vec3
- create
- new
- clone
- copy
- set
- add
- subtract
- sub
- multiply
- mul
- divide
- div
- ceil
- floor
- min
- max
- round
- scale
- scaleAndAdd
- distance
- dist
- squaredDistance
- sqrDist
- length
- len
- squaredLength
- sqrLen
- negate
- inverse
- inverseSafe
- normalize
- dot
- cross
- lerp
- hermite
- bezier
- random
- transformMat4
- transformMat3
- transformQuat
- rotateX
- rotateY
- rotateZ
- forEach
- angle
- str
- array
- exactEquals
- equals
- vec4
- quat
- mat2
- mat23
- mat3
- mat4
- create
- new
- clone
- copy
- set
- identity
- transpose
- invert
- adjoint
- determinant
- multiply
- mul
- translate
- scale
- rotate
- rotateX
- rotateY
- rotateZ
- fromTranslation
- fromScaling
- fromRotation
- fromXRotation
- fromYRotation
- fromZRotation
- fromRT
- getTranslation
- getScaling
- getRotation
- fromRTS
- fromRTSOrigin
- fromQuat
- frustum
- perspective
- perspectiveFromFieldOfView
- ortho
- lookAt
- str
- array
- frob
- add
- subtract
- sub
- multiplyScalar
- multiplyScalarAndAdd
- exactEquals
- equals
- sign
- abs
- min
- max
- isPow2
- log2
- log10
- popCount
- countTrailingZeros
- nextPow2
- prevPow2
- parity
- reverse
- interleave2
- deinterleave2
- interleave3
- deinterleave3
- nextCombination
Type: number
Properties
EPSILON
number
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
Returns Boolean True if the numbers are approximately equal, false otherwise.
Tests whether or not the arguments have approximately the same value by given maxDiff
Parameters
a
Number The first number to test.b
Number The second number to test.maxDiff
Number Maximum difference.
Returns Boolean True if the numbers are approximately equal, false otherwise.
Clamps a value between a minimum float and maximum float value.
Parameters
Returns number
Clamps a value between 0 and 1.
Parameters
val
number
Returns number
Parameters
Returns number
Convert Degree To Radian
Parameters
a
Number Angle in Degrees
Convert Radian To Degree
Parameters
a
Number Angle in Radian
Returns a floating-point random number between min (inclusive) and max (exclusive).
Parameters
Returns number the random number
Returns a random integer between min (inclusive) and max (exclusive).
Parameters
Returns number the random integer
Creates a new, empty vec2
Returns vec2 a new 2D vector
Creates a new vec2 initialized with the given values
Parameters
Returns vec2 a new 2D vector
Creates a new vec2 initialized with values from an existing vector
Parameters
a
vec2 vector to clone
Returns vec2 a new 2D vector
Copy the values from one vec2 to another
Parameters
Returns vec2 out
Set the components of a vec2 to the given values
Parameters
Returns vec2 out
Adds two vec2's
Parameters
Returns vec2 out
Subtracts vector b from vector a
Parameters
Returns vec2 out
Alias for vec2.subtract
Multiplies two vec2's
Parameters
Returns vec2 out
Alias for vec2.multiply
Divides two vec2's
Parameters
Returns vec2 out
Alias for vec2.divide
Math.ceil the components of a vec2
Parameters
Returns vec2 out
Math.floor the components of a vec2
Parameters
Returns vec2 out
Returns the minimum of two vec2's
Parameters
Returns vec2 out
Returns the maximum of two vec2's
Parameters
Returns vec2 out
Math.round the components of a vec2
Parameters
Returns vec2 out
Scales a vec2 by a scalar number
Parameters
Returns vec2 out
Adds two vec2's after scaling the second operand by a scalar value
Parameters
out
vec2 the receiving vectora
vec2 the first operandb
vec2 the second operandscale
Number the amount to scale b by before adding
Returns vec2 out
Calculates the euclidian distance between two vec2's
Parameters
Returns Number distance between a and b
Alias for vec2.distance
Calculates the squared euclidian distance between two vec2's
Parameters
Returns Number squared distance between a and b
Alias for vec2.squaredDistance
Calculates the length of a vec2
Parameters
a
vec2 vector to calculate length of
Returns Number length of a
Alias for vec2.length
Calculates the squared length of a vec2
Parameters
a
vec2 vector to calculate squared length of
Returns Number squared length of a
Alias for vec2.squaredLength
Negates the components of a vec2
Parameters
Returns vec2 out
Returns the inverse of the components of a vec2
Parameters
Returns vec2 out
Returns the inverse of the components of a vec2 safely
Parameters
Returns vec2 out
Normalize a vec2
Parameters
Returns vec2 out
Calculates the dot product of two vec2's
Parameters
Returns 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
Parameters
Returns vec3 out
Performs a linear interpolation between two vec2's
Parameters
out
vec2 the receiving vectora
vec2 the first operandb
vec2 the second operandt
Number interpolation amount between the two inputs
Returns vec2 out
Generates a random vector with the given scale
Parameters
out
vec2 the receiving vectorscale
Number? Length of the resulting vector. If ommitted, a unit vector will be returned
Returns vec2 out
Transforms the vec2 with a mat2
Parameters
Returns vec2 out
Transforms the vec2 with a mat23
Parameters
Returns vec2 out
Transforms the vec2 with a mat3 3rd vector component is implicitly '1'
Parameters
Returns vec2 out
Transforms the vec2 with a mat4 3rd vector component is implicitly '0' 4th vector component is implicitly '1'
Parameters
Returns vec2 out
Perform some operation over an array of vec2s.
Parameters
a
Array the array of vectors to iterate overstride
Number Number of elements between the start of each vec2. If 0 assumes tightly packedoffset
Number Number of elements to skip at the beginning of the arraycount
Number Number of vec2s to iterate over. If 0 iterates over entire arrayfn
Function Function to call for each vector in the arrayarg
Object? additional argument to pass to fn
Returns Array a
Returns a string representation of a vector
Parameters
a
vec2 vector to represent as a string
Returns String string representation of the vector
Returns typed array
Parameters
Returns array
Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Creates a new, empty vec3
Returns vec3 a new 3D vector
Creates a new vec3 initialized with the given values
Parameters
Returns vec3 a new 3D vector
Creates a new vec3 initialized with values from an existing vector
Parameters
a
vec3 vector to clone
Returns vec3 a new 3D vector
Copy the values from one vec3 to another
Parameters
Returns vec3 out
Set the components of a vec3 to the given values
Parameters
Returns vec3 out
Adds two vec3's
Parameters
Returns vec3 out
Subtracts vector b from vector a
Parameters
Returns vec3 out
Alias for vec3.subtract
Multiplies two vec3's
Parameters
Returns vec3 out
Alias for vec3.multiply
Divides two vec3's
Parameters
Returns vec3 out
Alias for vec3.divide
Math.ceil the components of a vec3
Parameters
Returns vec3 out
Math.floor the components of a vec3
Parameters
Returns vec3 out
Returns the minimum of two vec3's
Parameters
Returns vec3 out
Returns the maximum of two vec3's
Parameters
Returns vec3 out
Math.round the components of a vec3
Parameters
Returns vec3 out
Scales a vec3 by a scalar number
Parameters
Returns vec3 out
Adds two vec3's after scaling the second operand by a scalar value
Parameters
out
vec3 the receiving vectora
vec3 the first operandb
vec3 the second operandscale
Number the amount to scale b by before adding
Returns vec3 out
Calculates the euclidian distance between two vec3's
Parameters
Returns Number distance between a and b
Alias for vec3.distance
Calculates the squared euclidian distance between two vec3's
Parameters
Returns Number squared distance between a and b
Alias for vec3.squaredDistance
Calculates the length of a vec3
Parameters
a
vec3 vector to calculate length of
Returns Number length of a
Alias for vec3.length
Calculates the squared length of a vec3
Parameters
a
vec3 vector to calculate squared length of
Returns Number squared length of a
Alias for vec3.squaredLength
Negates the components of a vec3
Parameters
Returns vec3 out
Returns the inverse of the components of a vec3
Parameters
Returns vec3 out
Returns the inverse of the components of a vec3 safely
Parameters
Returns vec3 out
Normalize a vec3
Parameters
Returns vec3 out
Calculates the dot product of two vec3's
Parameters
Returns Number dot product of a and b
Computes the cross product of two vec3's
Parameters
Returns vec3 out
Performs a linear interpolation between two vec3's
Parameters
out
vec3 the receiving vectora
vec3 the first operandb
vec3 the second operandt
Number interpolation amount between the two inputs
Returns vec3 out
Performs a hermite interpolation with two control points
Parameters
out
vec3 the receiving vectora
vec3 the first operandb
vec3 the second operandc
vec3 the third operandd
vec3 the fourth operandt
Number interpolation amount between the two inputs
Returns vec3 out
Performs a bezier interpolation with two control points
Parameters
out
vec3 the receiving vectora
vec3 the first operandb
vec3 the second operandc
vec3 the third operandd
vec3 the fourth operandt
Number interpolation amount between the two inputs
Returns vec3 out
Generates a random vector with the given scale
Parameters
out
vec3 the receiving vectorscale
Number? Length of the resulting vector. If ommitted, a unit vector will be returned
Returns vec3 out
Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
Parameters
Returns vec3 out
Transforms the vec3 with a mat3.
Parameters
out
vec3 the receiving vectora
vec3 the vector to transformm
mat4 the 3x3 matrix to transform with
Returns vec3 out
Transforms the vec3 with a quat
Parameters
Returns vec3 out
Rotate a 3D vector around the x-axis
Parameters
out
vec3 The receiving vec3a
vec3 The vec3 point to rotateb
vec3 The origin of the rotationc
Number The angle of rotation
Returns vec3 out
Rotate a 3D vector around the y-axis
Parameters
out
vec3 The receiving vec3a
vec3 The vec3 point to rotateb
vec3 The origin of the rotationc
Number The angle of rotation
Returns vec3 out
Rotate a 3D vector around the z-axis
Parameters
out
vec3 The receiving vec3a
vec3 The vec3 point to rotateb
vec3 The origin of the rotationc
Number The angle of rotation
Returns vec3 out
Perform some operation over an array of vec3s.
Parameters
a
Array the array of vectors to iterate overstride
Number Number of elements between the start of each vec3. If 0 assumes tightly packedoffset
Number Number of elements to skip at the beginning of the arraycount
Number Number of vec3s to iterate over. If 0 iterates over entire arrayfn
Function Function to call for each vector in the arrayarg
Object? additional argument to pass to fn
Returns Array a
Get the angle between two 3D vectors
Parameters
Returns Number The angle in radians
Returns a string representation of a vector
Parameters
a
vec3 vector to represent as a string
Returns String string representation of the vector
Returns typed array
Parameters
Returns array
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Creates a new, empty vec4
Returns vec4 a new 4D vector
Creates a new vec4 initialized with the given values
Parameters
Returns vec4 a new 4D vector
Creates a new vec4 initialized with values from an existing vector
Parameters
a
vec4 vector to clone
Returns vec4 a new 4D vector
Copy the values from one vec4 to another
Parameters
Returns vec4 out
Set the components of a vec4 to the given values
Parameters
out
vec4 the receiving vectorx
Number X componenty
Number Y componentz
Number Z componentw
Number W component
Returns vec4 out
Adds two vec4's
Parameters
Returns vec4 out
Subtracts vector b from vector a
Parameters
Returns vec4 out
Alias for vec4.subtract
Multiplies two vec4's
Parameters
Returns vec4 out
Alias for vec4.multiply
Divides two vec4's
Parameters
Returns vec4 out
Alias for vec4.divide
Math.ceil the components of a vec4
Parameters
Returns vec4 out
Math.floor the components of a vec4
Parameters
Returns vec4 out
Returns the minimum of two vec4's
Parameters
Returns vec4 out
Returns the maximum of two vec4's
Parameters
Returns vec4 out
Math.round the components of a vec4
Parameters
Returns vec4 out
Scales a vec4 by a scalar number
Parameters
Returns vec4 out
Adds two vec4's after scaling the second operand by a scalar value
Parameters
out
vec4 the receiving vectora
vec4 the first operandb
vec4 the second operandscale
Number the amount to scale b by before adding
Returns vec4 out
Calculates the euclidian distance between two vec4's
Parameters
Returns Number distance between a and b
Alias for vec4.distance
Calculates the squared euclidian distance between two vec4's
Parameters
Returns Number squared distance between a and b
Alias for vec4.squaredDistance
Calculates the length of a vec4
Parameters
a
vec4 vector to calculate length of
Returns Number length of a
Alias for vec4.length
Calculates the squared length of a vec4
Parameters
a
vec4 vector to calculate squared length of
Returns Number squared length of a
Alias for vec4.squaredLength
Negates the components of a vec4
Parameters
Returns vec4 out
Returns the inverse of the components of a vec4
Parameters
Returns vec4 out
Returns the inverse of the components of a vec4 safely
Parameters
Returns vec4 out
Normalize a vec4
Parameters
Returns vec4 out
Calculates the dot product of two vec4's
Parameters
Returns Number dot product of a and b
Performs a linear interpolation between two vec4's
Parameters
out
vec4 the receiving vectora
vec4 the first operandb
vec4 the second operandt
Number interpolation amount between the two inputs
Returns vec4 out
Generates a random vector with the given scale
Parameters
out
vec4 the receiving vectorscale
Number? Length of the resulting vector. If ommitted, a unit vector will be returned
Returns vec4 out
Transforms the vec4 with a mat4.
Parameters
Returns vec4 out
Transforms the vec4 with a quat
Parameters
Returns vec4 out
Perform some operation over an array of vec4s.
Parameters
a
Array the array of vectors to iterate overstride
Number Number of elements between the start of each vec4. If 0 assumes tightly packedoffset
Number Number of elements to skip at the beginning of the arraycount
Number Number of vec4s to iterate over. If 0 iterates over entire arrayfn
Function Function to call for each vector in the arrayarg
Object? additional argument to pass to fn
Returns Array a
Returns a string representation of a vector
Parameters
a
vec4 vector to represent as a string
Returns String string representation of the vector
Returns typed array
Parameters
Returns array
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Returns whether or not the vectors have approximately the same elements in the same position.
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Creates a new identity quat
Returns quat a new quaternion
Creates a new quat initialized with the given values
Parameters
Returns quat a new quaternion
Creates a new quat initialized with values from an existing quaternion
Parameters
a
quat quaternion to clone
Returns quat a new quaternion
Copy the values from one quat to another
Parameters
Returns quat out
Set the components of a quat to the given values
Parameters
out
quat the receiving quaternionx
Number X componenty
Number Y componentz
Number Z componentw
Number W component
Returns quat out
Set a quat to the identity quaternion
Parameters
out
quat the receiving quaternion
Returns quat out
Sets a quaternion to represent the shortest rotation from one vector to another.
Both vectors are assumed to be unit length.
Parameters
Returns quat out
Gets the rotation axis and angle for a given quaternion. If a quaternion is created with fromAxisAngle, 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
Returns Number Angle, in radians, of the rotation
Adds two quat's
Parameters
Returns quat out
Multiplies two quat's
Parameters
Returns quat out
Alias for quat.multiply
Scales a quat by a scalar number
Parameters
Returns quat out
Rotates a quaternion by the given angle about the X axis
Parameters
out
quat quat receiving operation resulta
quat quat to rotaterad
number angle (in radians) to rotate
Returns quat out
Rotates a quaternion by the given angle about the Y axis
Parameters
out
quat quat receiving operation resulta
quat quat to rotaterad
number angle (in radians) to rotate
Returns quat out
Rotates a quaternion by the given angle about the Z axis
Parameters
out
quat quat receiving operation resulta
quat quat to rotaterad
number angle (in radians) to rotate
Returns 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.
Parameters
Returns quat out
Calculates the dot product of two quat's
Parameters
Returns Number dot product of a and b
Performs a linear interpolation between two quat's
Parameters
out
quat the receiving quaterniona
quat the first operandb
quat the second operandt
Number interpolation amount between the two inputs
Returns quat out
Performs a spherical linear interpolation between two quat
Parameters
out
quat the receiving quaterniona
quat the first operandb
quat the second operandt
Number interpolation amount between the two inputs
Returns quat out
Performs a spherical linear interpolation with two control points
Parameters
out
quat the receiving quaterniona
quat the first operandb
quat the second operandc
quat the third operandd
quat the fourth operandt
Number interpolation amount
Returns quat out
Calculates the inverse of a quat
Parameters
Returns 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.
Parameters
Returns quat out
Calculates the length of a quat
Parameters
a
quat vector to calculate length of
Returns Number length of a
Alias for quat.length
Calculates the squared length of a quat
Parameters
a
quat vector to calculate squared length of
Returns Number squared length of a
Alias for quat.squaredLength
Normalize a quat
Parameters
Returns 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.
Parameters
xAxis
vec3 the vector representing the local "right" directionyAxis
vec3 the vector representing the local "up" directionzAxis
vec3 the vector representing the viewing direction
Returns quat out
Calculates a quaternion from view direction and up direction
Parameters
out
quat mat3 receiving operation resultview
vec3 view direction (must be normalized)up
vec3? up direction, default is (0,1,0) (must be normalized)
Returns quat out
Sets a quat from the given angle and rotation axis, then returns it.
Parameters
out
quat the receiving quaternionaxis
vec3 the axis around which to rotaterad
Number the angle in radians
Returns 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.
Parameters
Returns quat out
Creates a quaternion from the given euler angle x, y, z.
Parameters
out
quat the receiving quaternionAngle
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.x
y
z
Returns quat out
Returns a string representation of a quatenion
Parameters
a
quat vector to represent as a string
Returns String string representation of the vector
Returns typed array
Parameters
Returns array
Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Returns whether or not the quaternions have approximately the same elements in the same position.
Parameters
Returns Boolean True if the vectors are equal, false otherwise.
Creates a new identity mat2
Returns mat2 a new 2x2 matrix
Create a new mat2 with the given values
Parameters
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
Creates a new mat2 initialized with values from an existing matrix
Parameters
a
mat2 matrix to clone
Returns mat2 a new 2x2 matrix
Copy the values from one mat2 to another
Parameters
Returns mat2 out
Set a mat2 to the identity matrix
Parameters
out
mat2 the receiving matrix
Returns mat2 out
Set the components of a mat2 to the given values
Parameters
out
mat2 the receiving matrixm00
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 the values of a mat2
Parameters
Returns mat2 out
Inverts a mat2
Parameters
Returns mat2 out
Calculates the adjugate of a mat2
Parameters
Returns mat2 out
Calculates the determinant of a mat2
Parameters
a
mat2 the source matrix
Returns Number determinant of a
Multiplies two mat2's
Parameters
Returns mat2 out
Alias for mat2.multiply
Rotates a mat2 by the given angle
Parameters
out
mat2 the receiving matrixa
mat2 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns mat2 out
Scales the mat2 by the dimensions in the given vec2
Parameters
Returns 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);
Parameters
Returns 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);
Parameters
Returns mat2 out
Returns a string representation of a mat2
Parameters
a
mat2 matrix to represent as a string
Returns String string representation of the matrix
Returns typed array
Parameters
Returns array
Returns Frobenius norm of a mat2
Parameters
a
mat2 the matrix to calculate Frobenius norm of
Returns Number Frobenius norm
Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
Parameters
L
mat2 the lower triangular matrixD
mat2 the diagonal matrixU
mat2 the upper triangular matrixa
mat2 the input matrix to factorize
Adds two mat2's
Parameters
Returns mat2 out
Subtracts matrix b from matrix a
Parameters
Returns mat2 out
Alias for mat2.subtract
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Multiply each element of the matrix by a scalar.
Parameters
out
mat2 the receiving matrixa
mat2 the matrix to scaleb
Number amount to scale the matrix's elements by
Returns mat2 out
Adds two mat2's after multiplying each element of the second operand by a scalar value.
Parameters
out
mat2 the receiving vectora
mat2 the first operandb
mat2 the second operandscale
Number the amount to scale b's elements by before adding
Returns mat2 out
A mat23 contains six elements defined as:
[a, c, tx, b, d, ty]
This is a short form for the 3x3 matrix:
[a, c, tx, b, d, ty, 0, 0, 1]
The last row is ignored so the array is shorter and operations are faster.
Creates a new identity mat23
Returns mat23 a new 2x3 matrix
Create a new mat23 with the given values
Parameters
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 mat23 A new mat23
Creates a new mat23 initialized with values from an existing matrix
Parameters
a
mat23 matrix to clone
Returns mat23 a new 2x3 matrix
Copy the values from one mat23 to another
Parameters
Returns mat23 out
Set a mat23 to the identity matrix
Parameters
out
mat23 the receiving matrix
Returns mat23 out
Set the components of a mat23 to the given values
Parameters
out
mat23 the receiving matrixa
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 mat23 out
Inverts a mat23
Parameters
Returns mat23 out
Calculates the determinant of a mat23
Parameters
a
mat23 the source matrix
Returns Number determinant of a
Multiplies two mat23's
Parameters
Returns mat23 out
Alias for mat23.multiply
Rotates a mat23 by the given angle
Parameters
out
mat23 the receiving matrixa
mat23 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns mat23 out
Scales the mat23 by the dimensions in the given vec2
Parameters
out
mat23 the receiving matrixa
mat23 the matrix to translatev
vec2 the vec2 to scale the matrix by
Returns mat23 out
Translates the mat23 by the dimensions in the given vec2
Parameters
out
mat23 the receiving matrixa
mat23 the matrix to translatev
vec2 the vec2 to translate the matrix by
Returns mat23 out
Creates a matrix from a given angle This is equivalent to (but much faster than):
mat23.identity(dest);
mat23.rotate(dest, dest, rad);
Parameters
Returns mat23 out
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat23.identity(dest);
mat23.scale(dest, dest, vec);
Parameters
Returns mat23 out
Creates a matrix from a vector translation This is equivalent to (but much faster than):
mat23.identity(dest);
mat23.translate(dest, dest, vec);
Parameters
Returns mat23 out
Returns a string representation of a mat23
Parameters
a
mat23 matrix to represent as a string
Returns String string representation of the matrix
Returns typed array
Parameters
Returns array
Returns Frobenius norm of a mat23
Parameters
a
mat23 the matrix to calculate Frobenius norm of
Returns Number Frobenius norm
Adds two mat23's
Parameters
Returns mat23 out
Subtracts matrix b from matrix a
Parameters
Returns mat23 out
Alias for mat23.subtract
Multiply each element of the matrix by a scalar.
Parameters
out
mat23 the receiving matrixa
mat23 the matrix to scaleb
Number amount to scale the matrix's elements by
Returns mat23 out
Adds two mat23's after multiplying each element of the second operand by a scalar value.
Parameters
out
mat23 the receiving vectora
mat23 the first operandb
mat23 the second operandscale
Number the amount to scale b's elements by before adding
Returns mat23 out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Creates a new identity mat3
Returns mat3 a new 3x3 matrix
Create a new mat3 with the given values
Parameters
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
Creates a new mat3 initialized with values from an existing matrix
Parameters
a
mat3 matrix to clone
Returns mat3 a new 3x3 matrix
Copy the values from one mat3 to another
Parameters
Returns mat3 out
Set the components of a mat3 to the given values
Parameters
out
mat3 the receiving matrixm00
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
Set a mat3 to the identity matrix
Parameters
out
mat3 the receiving matrix
Returns mat3 out
Transpose the values of a mat3
Parameters
Returns mat3 out
Inverts a mat3
Parameters
Returns mat3 out
Calculates the adjugate of a mat3
Parameters
Returns mat3 out
Calculates the determinant of a mat3
Parameters
a
mat3 the source matrix
Returns Number determinant of a
Multiplies two mat3's
Parameters
Returns mat3 out
Alias for mat3.multiply
Translate a mat3 by the given vector
Parameters
Returns mat3 out
Rotates a mat3 by the given angle
Parameters
out
mat3 the receiving matrixa
mat3 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns mat3 out
Scales the mat3 by the dimensions in the given vec2
Parameters
Returns mat3 out
Copies the upper-left 3x3 values into the given mat3.
Parameters
Returns 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);
Parameters
Returns 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);
Parameters
Returns 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);
Parameters
Returns mat3 out
Copies the values from a mat2d into a mat3
Parameters
out
mat3 the receiving matrixa
mat2d the matrix to copy
Returns mat3 out
Calculates a 3x3 matrix from the given quaternion
Parameters
Returns mat3 out
Calculates a 3x3 matrix from view direction and up direction
Parameters
out
mat3 mat3 receiving operation resultview
vec3 view direction (must be normalized)up
vec3? up direction, default is (0,1,0) (must be normalized)
Returns mat3 out
Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
Parameters
Returns mat3 out
Returns a string representation of a mat3
Parameters
a
mat3 matrix to represent as a string
Returns String string representation of the matrix
Returns typed array
Parameters
Returns array
Returns Frobenius norm of a mat3
Parameters
a
mat3 the matrix to calculate Frobenius norm of
Returns Number Frobenius norm
Adds two mat3's
Parameters
Returns mat3 out
Subtracts matrix b from matrix a
Parameters
Returns mat3 out
Alias for mat3.subtract
Multiply each element of the matrix by a scalar.
Parameters
out
mat3 the receiving matrixa
mat3 the matrix to scaleb
Number amount to scale the matrix's elements by
Returns mat3 out
Adds two mat3's after multiplying each element of the second operand by a scalar value.
Parameters
out
mat3 the receiving vectora
mat3 the first operandb
mat3 the second operandscale
Number the amount to scale b's elements by before adding
Returns mat3 out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Creates a new identity mat4
Returns mat4 a new 4x4 matrix
Create a new mat4 with the given values
Parameters
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
Creates a new mat4 initialized with values from an existing matrix
Parameters
a
mat4 matrix to clone
Returns mat4 a new 4x4 matrix
Copy the values from one mat4 to another
Parameters
Returns mat4 out
Set the components of a mat4 to the given values
Parameters
out
mat4 the receiving matrixm00
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
Set a mat4 to the identity matrix
Parameters
out
mat4 the receiving matrix
Returns mat4 out
Transpose the values of a mat4
Parameters
Returns mat4 out
Inverts a mat4
Parameters
Returns mat4 out
Calculates the adjugate of a mat4
Parameters
Returns mat4 out
Calculates the determinant of a mat4
Parameters
a
mat4 the source matrix
Returns Number determinant of a
Multiplies two mat4's explicitly
Parameters
Returns mat4 out
Alias for mat4.multiply
Translate a mat4 by the given vector
Parameters
Returns mat4 out
Scales the mat4 by the dimensions in the given vec3
Parameters
Returns mat4 out
Rotates a mat4 by the given angle around the given axis
Parameters
out
mat4 the receiving matrixa
mat4 the matrix to rotaterad
Number the angle to rotate the matrix byaxis
vec3 the axis to rotate around
Returns mat4 out
Rotates a matrix by the given angle around the X axis
Parameters
out
mat4 the receiving matrixa
mat4 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns mat4 out
Rotates a matrix by the given angle around the Y axis
Parameters
out
mat4 the receiving matrixa
mat4 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns mat4 out
Rotates a matrix by the given angle around the Z axis
Parameters
out
mat4 the receiving matrixa
mat4 the matrix to rotaterad
Number the angle to rotate the matrix by
Returns 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);
Parameters
Returns 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);
Parameters
Returns 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);
Parameters
out
mat4 mat4 receiving operation resultrad
Number the angle to rotate the matrix byaxis
vec3 the axis to rotate around
Returns 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);
Parameters
Returns 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);
Parameters
Returns 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);
Parameters
Returns 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();
quat.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
Parameters
Returns mat4 out
Returns the translation vector component of a transformation matrix. If a matrix is built with fromRT, the returned vector will be the same as the translation vector originally supplied.
Parameters
Returns vec3 out
Returns the scaling factor component of a transformation matrix. If a matrix is built with fromRTS with a normalized Quaternion paramter, the returned vector will be the same as the scaling vector originally supplied.
Parameters
Returns vec3 out
Returns a quaternion representing the rotational component of a transformation matrix. If a matrix is built with fromRT, the returned quaternion will be the same as the quaternion originally supplied.
Parameters
Returns 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();
quat.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
Parameters
out
mat4 mat4 receiving operation resultq
quat Rotation quaternionv
vec3 Translation vectors
vec3 Scaling vector
Returns 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();
quat.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
mat4.translate(dest, negativeOrigin);
Parameters
out
mat4 mat4 receiving operation resultq
quat Rotation quaternionv
vec3 Translation vectors
vec3 Scaling vectoro
vec3 The origin vector around which to scale and rotate
Returns mat4 out
Calculates a 4x4 matrix from the given quaternion
Parameters
Returns mat4 out
Generates a frustum matrix with the given bounds
Parameters
out
mat4 mat4 frustum matrix will be written intoleft
Number Left bound of the frustumright
Number Right bound of the frustumbottom
Number Bottom bound of the frustumtop
Number Top bound of the frustumnear
Number Near bound of the frustumfar
Number Far bound of the frustum
Returns mat4 out
Generates a perspective projection matrix with the given bounds
Parameters
out
mat4 mat4 frustum matrix will be written intofovy
number Vertical field of view in radiansaspect
number Aspect ratio. typically viewport width/heightnear
number Near bound of the frustumfar
number Far bound of the frustum
Returns 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.
Parameters
out
mat4 mat4 frustum matrix will be written intofov
Object Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegreesnear
number Near bound of the frustumfar
number Far bound of the frustum
Returns mat4 out
Generates a orthogonal projection matrix with the given bounds
Parameters
out
mat4 mat4 frustum matrix will be written intoleft
number Left bound of the frustumright
number Right bound of the frustumbottom
number Bottom bound of the frustumtop
number Top bound of the frustumnear
number Near bound of the frustumfar
number Far bound of the frustum
Returns mat4 out
Generates a look-at matrix with the given eye position, focal point, and up axis
Parameters
out
mat4 mat4 frustum matrix will be written intoeye
vec3 Position of the viewercenter
vec3 Point the viewer is looking atup
vec3 vec3 pointing up
Returns mat4 out
Returns a string representation of a mat4
Parameters
a
mat4 matrix to represent as a string
Returns String string representation of the matrix
Returns typed array
Parameters
Returns array
Returns Frobenius norm of a mat4
Parameters
a
mat4 the matrix to calculate Frobenius norm of
Returns Number Frobenius norm
Adds two mat4's
Parameters
Returns mat4 out
Subtracts matrix b from matrix a
Parameters
Returns mat4 out
Alias for mat4.subtract
Multiply each element of the matrix by a scalar.
Parameters
out
mat4 the receiving matrixa
mat4 the matrix to scaleb
Number amount to scale the matrix's elements by
Returns mat4 out
Adds two mat4's after multiplying each element of the second operand by a scalar value.
Parameters
out
mat4 the receiving vectora
mat4 the first operandb
mat4 the second operandscale
Number the amount to scale b's elements by before adding
Returns mat4 out
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters
Returns Boolean True if the matrices are equal, false otherwise.
Bit twiddling hacks for JavaScript.
Author: Mikola Lysenko
Ported from Stanford bit twiddling hack library: http://graphics.stanford.edu/~seander/bithacks.html
Returns -1, 0, +1 depending on sign of x
Parameters
v
number
Returns number
Computes absolute value of integer
Parameters
v
number
Returns number
Computes minimum of integers x and y
Parameters
Returns number
Computes maximum of integers x and y
Parameters
Returns number
Checks if a number is a power of two
Parameters
v
number
Returns boolean
Computes log base 2 of v
Parameters
v
number
Returns number
Computes log base 10 of v
Parameters
v
number
Returns number
Counts number of bits
Parameters
v
number
Returns number
Counts number of trailing zeros
Parameters
v
number
Returns number
Rounds to next power of 2
Parameters
v
number
Returns number
Rounds down to previous power of 2
Parameters
v
number
Returns number
Computes parity of word
Parameters
v
number
Returns number
Reverse bits in a 32 bit word
Parameters
v
number
Returns number
Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes
Parameters
Returns number
Extracts the nth interleaved component
Parameters
Returns number
Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes
Parameters
Returns number
Extracts nth interleaved component of a 3-tuple
Parameters
Returns number
Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page)
Parameters
v
number
Returns number