- 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
EPSILONnumber
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
aNumber The first number to test.bNumber The second number to test.maxDiffNumber 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
valnumber
Returns number
Parameters
Returns number
Convert Degree To Radian
Parameters
aNumber Angle in Degrees
Convert Radian To Degree
Parameters
aNumber 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
avec2 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
outvec2 the receiving vectoravec2 the first operandbvec2 the second operandscaleNumber 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
avec2 vector to calculate length of
Returns Number length of a
Alias for vec2.length
Calculates the squared length of a vec2
Parameters
avec2 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
outvec2 the receiving vectoravec2 the first operandbvec2 the second operandtNumber interpolation amount between the two inputs
Returns vec2 out
Generates a random vector with the given scale
Parameters
outvec2 the receiving vectorscaleNumber? 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
aArray the array of vectors to iterate overstrideNumber Number of elements between the start of each vec2. If 0 assumes tightly packedoffsetNumber Number of elements to skip at the beginning of the arraycountNumber Number of vec2s to iterate over. If 0 iterates over entire arrayfnFunction Function to call for each vector in the arrayargObject? additional argument to pass to fn
Returns Array a
Returns a string representation of a vector
Parameters
avec2 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
avec3 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
outvec3 the receiving vectoravec3 the first operandbvec3 the second operandscaleNumber 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
avec3 vector to calculate length of
Returns Number length of a
Alias for vec3.length
Calculates the squared length of a vec3
Parameters
avec3 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
outvec3 the receiving vectoravec3 the first operandbvec3 the second operandtNumber interpolation amount between the two inputs
Returns vec3 out
Performs a hermite interpolation with two control points
Parameters
outvec3 the receiving vectoravec3 the first operandbvec3 the second operandcvec3 the third operanddvec3 the fourth operandtNumber interpolation amount between the two inputs
Returns vec3 out
Performs a bezier interpolation with two control points
Parameters
outvec3 the receiving vectoravec3 the first operandbvec3 the second operandcvec3 the third operanddvec3 the fourth operandtNumber interpolation amount between the two inputs
Returns vec3 out
Generates a random vector with the given scale
Parameters
outvec3 the receiving vectorscaleNumber? 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
outvec3 the receiving vectoravec3 the vector to transformmmat4 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
outvec3 The receiving vec3avec3 The vec3 point to rotatebvec3 The origin of the rotationcNumber The angle of rotation
Returns vec3 out
Rotate a 3D vector around the y-axis
Parameters
outvec3 The receiving vec3avec3 The vec3 point to rotatebvec3 The origin of the rotationcNumber The angle of rotation
Returns vec3 out
Rotate a 3D vector around the z-axis
Parameters
outvec3 The receiving vec3avec3 The vec3 point to rotatebvec3 The origin of the rotationcNumber The angle of rotation
Returns vec3 out
Perform some operation over an array of vec3s.
Parameters
aArray the array of vectors to iterate overstrideNumber Number of elements between the start of each vec3. If 0 assumes tightly packedoffsetNumber Number of elements to skip at the beginning of the arraycountNumber Number of vec3s to iterate over. If 0 iterates over entire arrayfnFunction Function to call for each vector in the arrayargObject? 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
avec3 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
avec4 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
outvec4 the receiving vectorxNumber X componentyNumber Y componentzNumber Z componentwNumber 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
outvec4 the receiving vectoravec4 the first operandbvec4 the second operandscaleNumber 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
avec4 vector to calculate length of
Returns Number length of a
Alias for vec4.length
Calculates the squared length of a vec4
Parameters
avec4 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
outvec4 the receiving vectoravec4 the first operandbvec4 the second operandtNumber interpolation amount between the two inputs
Returns vec4 out
Generates a random vector with the given scale
Parameters
outvec4 the receiving vectorscaleNumber? 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
aArray the array of vectors to iterate overstrideNumber Number of elements between the start of each vec4. If 0 assumes tightly packedoffsetNumber Number of elements to skip at the beginning of the arraycountNumber Number of vec4s to iterate over. If 0 iterates over entire arrayfnFunction Function to call for each vector in the arrayargObject? additional argument to pass to fn
Returns Array a
Returns a string representation of a vector
Parameters
avec4 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
aquat 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
outquat the receiving quaternionxNumber X componentyNumber Y componentzNumber Z componentwNumber W component
Returns quat out
Set a quat to the identity quaternion
Parameters
outquat 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
outquat quat receiving operation resultaquat quat to rotateradnumber angle (in radians) to rotate
Returns quat out
Rotates a quaternion by the given angle about the Y axis
Parameters
outquat quat receiving operation resultaquat quat to rotateradnumber angle (in radians) to rotate
Returns quat out
Rotates a quaternion by the given angle about the Z axis
Parameters
outquat quat receiving operation resultaquat quat to rotateradnumber 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
outquat the receiving quaternionaquat the first operandbquat the second operandtNumber interpolation amount between the two inputs
Returns quat out
Performs a spherical linear interpolation between two quat
Parameters
outquat the receiving quaternionaquat the first operandbquat the second operandtNumber interpolation amount between the two inputs
Returns quat out
Performs a spherical linear interpolation with two control points
Parameters
outquat the receiving quaternionaquat the first operandbquat the second operandcquat the third operanddquat the fourth operandtNumber 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
aquat vector to calculate length of
Returns Number length of a
Alias for quat.length
Calculates the squared length of a quat
Parameters
aquat 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
xAxisvec3 the vector representing the local "right" directionyAxisvec3 the vector representing the local "up" directionzAxisvec3 the vector representing the viewing direction
Returns quat out
Calculates a quaternion from view direction and up direction
Parameters
outquat mat3 receiving operation resultviewvec3 view direction (must be normalized)upvec3? 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
outquat the receiving quaternionaxisvec3 the axis around which to rotateradNumber 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
outquat the receiving quaternionAnglex to rotate around X axis in degrees.Angley to rotate around Y axis in degrees.Anglez to rotate around Z axis in degrees.xyz
Returns quat out
Returns a string representation of a quatenion
Parameters
aquat 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
m00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m10Number Component in column 1, row 0 position (index 2)m11Number 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
amat2 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
outmat2 the receiving matrix
Returns mat2 out
Set the components of a mat2 to the given values
Parameters
outmat2 the receiving matrixm00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m10Number Component in column 1, row 0 position (index 2)m11Number 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
amat2 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
outmat2 the receiving matrixamat2 the matrix to rotateradNumber 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
amat2 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
amat2 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
Lmat2 the lower triangular matrixDmat2 the diagonal matrixUmat2 the upper triangular matrixamat2 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
outmat2 the receiving matrixamat2 the matrix to scalebNumber 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
outmat2 the receiving vectoramat2 the first operandbmat2 the second operandscaleNumber 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
aNumber Component A (index 0)bNumber Component B (index 1)cNumber Component C (index 2)dNumber Component D (index 3)txNumber Component TX (index 4)tyNumber Component TY (index 5)
Returns mat23 A new mat23
Creates a new mat23 initialized with values from an existing matrix
Parameters
amat23 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
outmat23 the receiving matrix
Returns mat23 out
Set the components of a mat23 to the given values
Parameters
outmat23 the receiving matrixaNumber Component A (index 0)bNumber Component B (index 1)cNumber Component C (index 2)dNumber Component D (index 3)txNumber Component TX (index 4)tyNumber Component TY (index 5)
Returns mat23 out
Inverts a mat23
Parameters
Returns mat23 out
Calculates the determinant of a mat23
Parameters
amat23 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
outmat23 the receiving matrixamat23 the matrix to rotateradNumber the angle to rotate the matrix by
Returns mat23 out
Scales the mat23 by the dimensions in the given vec2
Parameters
outmat23 the receiving matrixamat23 the matrix to translatevvec2 the vec2 to scale the matrix by
Returns mat23 out
Translates the mat23 by the dimensions in the given vec2
Parameters
outmat23 the receiving matrixamat23 the matrix to translatevvec2 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
amat23 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
amat23 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
outmat23 the receiving matrixamat23 the matrix to scalebNumber 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
outmat23 the receiving vectoramat23 the first operandbmat23 the second operandscaleNumber 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
m00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m02Number Component in column 0, row 2 position (index 2)m10Number Component in column 1, row 0 position (index 3)m11Number Component in column 1, row 1 position (index 4)m12Number Component in column 1, row 2 position (index 5)m20Number Component in column 2, row 0 position (index 6)m21Number Component in column 2, row 1 position (index 7)m22Number 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
amat3 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
outmat3 the receiving matrixm00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m02Number Component in column 0, row 2 position (index 2)m10Number Component in column 1, row 0 position (index 3)m11Number Component in column 1, row 1 position (index 4)m12Number Component in column 1, row 2 position (index 5)m20Number Component in column 2, row 0 position (index 6)m21Number Component in column 2, row 1 position (index 7)m22Number Component in column 2, row 2 position (index 8)
Returns mat3 out
Set a mat3 to the identity matrix
Parameters
outmat3 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
amat3 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
outmat3 the receiving matrixamat3 the matrix to rotateradNumber 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
outmat3 the receiving matrixamat2d 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
outmat3 mat3 receiving operation resultviewvec3 view direction (must be normalized)upvec3? 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
amat3 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
amat3 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
outmat3 the receiving matrixamat3 the matrix to scalebNumber 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
outmat3 the receiving vectoramat3 the first operandbmat3 the second operandscaleNumber 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
m00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m02Number Component in column 0, row 2 position (index 2)m03Number Component in column 0, row 3 position (index 3)m10Number Component in column 1, row 0 position (index 4)m11Number Component in column 1, row 1 position (index 5)m12Number Component in column 1, row 2 position (index 6)m13Number Component in column 1, row 3 position (index 7)m20Number Component in column 2, row 0 position (index 8)m21Number Component in column 2, row 1 position (index 9)m22Number Component in column 2, row 2 position (index 10)m23Number Component in column 2, row 3 position (index 11)m30Number Component in column 3, row 0 position (index 12)m31Number Component in column 3, row 1 position (index 13)m32Number Component in column 3, row 2 position (index 14)m33Number 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
amat4 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
outmat4 the receiving matrixm00Number Component in column 0, row 0 position (index 0)m01Number Component in column 0, row 1 position (index 1)m02Number Component in column 0, row 2 position (index 2)m03Number Component in column 0, row 3 position (index 3)m10Number Component in column 1, row 0 position (index 4)m11Number Component in column 1, row 1 position (index 5)m12Number Component in column 1, row 2 position (index 6)m13Number Component in column 1, row 3 position (index 7)m20Number Component in column 2, row 0 position (index 8)m21Number Component in column 2, row 1 position (index 9)m22Number Component in column 2, row 2 position (index 10)m23Number Component in column 2, row 3 position (index 11)m30Number Component in column 3, row 0 position (index 12)m31Number Component in column 3, row 1 position (index 13)m32Number Component in column 3, row 2 position (index 14)m33Number Component in column 3, row 3 position (index 15)
Returns mat4 out
Set a mat4 to the identity matrix
Parameters
outmat4 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
amat4 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
outmat4 the receiving matrixamat4 the matrix to rotateradNumber the angle to rotate the matrix byaxisvec3 the axis to rotate around
Returns mat4 out
Rotates a matrix by the given angle around the X axis
Parameters
outmat4 the receiving matrixamat4 the matrix to rotateradNumber the angle to rotate the matrix by
Returns mat4 out
Rotates a matrix by the given angle around the Y axis
Parameters
outmat4 the receiving matrixamat4 the matrix to rotateradNumber the angle to rotate the matrix by
Returns mat4 out
Rotates a matrix by the given angle around the Z axis
Parameters
outmat4 the receiving matrixamat4 the matrix to rotateradNumber 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
outmat4 mat4 receiving operation resultradNumber the angle to rotate the matrix byaxisvec3 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
outmat4 mat4 receiving operation resultqquat Rotation quaternionvvec3 Translation vectorsvec3 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
outmat4 mat4 receiving operation resultqquat Rotation quaternionvvec3 Translation vectorsvec3 Scaling vectorovec3 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
outmat4 mat4 frustum matrix will be written intoleftNumber Left bound of the frustumrightNumber Right bound of the frustumbottomNumber Bottom bound of the frustumtopNumber Top bound of the frustumnearNumber Near bound of the frustumfarNumber Far bound of the frustum
Returns mat4 out
Generates a perspective projection matrix with the given bounds
Parameters
outmat4 mat4 frustum matrix will be written intofovynumber Vertical field of view in radiansaspectnumber Aspect ratio. typically viewport width/heightnearnumber Near bound of the frustumfarnumber 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
outmat4 mat4 frustum matrix will be written intofovObject Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegreesnearnumber Near bound of the frustumfarnumber Far bound of the frustum
Returns mat4 out
Generates a orthogonal projection matrix with the given bounds
Parameters
outmat4 mat4 frustum matrix will be written intoleftnumber Left bound of the frustumrightnumber Right bound of the frustumbottomnumber Bottom bound of the frustumtopnumber Top bound of the frustumnearnumber Near bound of the frustumfarnumber Far bound of the frustum
Returns mat4 out
Generates a look-at matrix with the given eye position, focal point, and up axis
Parameters
outmat4 mat4 frustum matrix will be written intoeyevec3 Position of the viewercentervec3 Point the viewer is looking atupvec3 vec3 pointing up
Returns mat4 out
Returns a string representation of a mat4
Parameters
amat4 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
amat4 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
outmat4 the receiving matrixamat4 the matrix to scalebNumber 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
outmat4 the receiving vectoramat4 the first operandbmat4 the second operandscaleNumber 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
vnumber
Returns number
Computes absolute value of integer
Parameters
vnumber
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
vnumber
Returns boolean
Computes log base 2 of v
Parameters
vnumber
Returns number
Computes log base 10 of v
Parameters
vnumber
Returns number
Counts number of bits
Parameters
vnumber
Returns number
Counts number of trailing zeros
Parameters
vnumber
Returns number
Rounds to next power of 2
Parameters
vnumber
Returns number
Rounds down to previous power of 2
Parameters
vnumber
Returns number
Computes parity of word
Parameters
vnumber
Returns number
Reverse bits in a 32 bit word
Parameters
vnumber
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
vnumber
Returns number