Class mat4
4x4 Matrix
Defined in: glMatrix.js.
Constructor Attributes | Constructor Name and Description |
---|---|
mat4()
|
Method Attributes | Method Name and Description |
---|---|
<static> |
mat4.create(mat)
Creates a new instance of a mat4 using the default array type
Any javascript array-like object containing at least 16 numeric elements can serve as a mat4
|
<static> |
mat4.determinant(mat)
Calculates the determinant of a mat4
|
<static> |
mat4.frustum(left, right, bottom, top, near, far, dest)
Generates a frustum matrix with the given bounds
|
<static> |
mat4.identity(dest)
Sets a mat4 to an identity matrix
|
<static> |
mat4.inverse(mat, dest, dest)
Calculates the inverse matrix of a mat4
|
<static> |
mat4.lookAt(eye, center, up, dest)
Generates a look-at matrix with the given eye position, focal point, and up axis
|
<static> |
mat4.multiply(mat, mat2, dest)
Performs a matrix multiplication
|
<static> |
mat4.multiplyVec3(mat, vec, dest)
Transforms a vec3 with the given matrix
4th vector component is implicitly '1'
|
<static> |
mat4.multiplyVec4(mat, vec, dest)
Transforms a vec4 with the given matrix
|
<static> |
mat4.ortho(left, right, bottom, top, near, far, dest)
Generates a orthogonal projection matrix with the given bounds
|
<static> |
mat4.perspective(fovy, aspect, near, far, dest)
Generates a perspective projection matrix with the given bounds
|
<static> |
mat4.project(mat, vec, dest)
Project a vec3
|
<static> |
mat4.rotate(mat, angle, axis, dest)
Rotates a matrix by the given angle around the specified axis
If rotating around a primary axis (X,Y,Z) one of the specialized rotation functions should be used instead for performance
|
<static> |
mat4.rotateVec3(mat, vec, dest)
mat4.rotateVec3
Rotate a vec3 with the given matrix
Params:
mat - mat4 to transform the vector with
vec - vec3 to transform
dest - Optional, vec3 receiving operation result.
|
<static> |
mat4.rotateX(mat, angle, dest)
Rotates a matrix by the given angle around the X axis
|
<static> |
mat4.rotateY(mat, angle, dest)
Rotates a matrix by the given angle around the Y axis
|
<static> |
mat4.rotateZ(mat, angle, dest)
Rotates a matrix by the given angle around the Z axis
|
<static> |
mat4.scale(mat, vec, dest, dest)
Scales a matrix by the given vector
|
<static> |
mat4.set(mat, dest)
Copies the values of one mat4 to another
|
<static> |
mat4.str(mat)
Returns a string representation of a mat4
|
<static> |
mat4.toMat3(mat, dest)
Copies the upper 3x3 elements of a mat4 into a mat3
|
<static> |
mat4.toRotationMat(mat, dest)
Copies the upper 3x3 elements of a mat4 into another mat4
|
<static> |
mat4.translate(mat, vec, dest)
Translates a matrix by the given vector
|
<static> |
mat4.transpose(mat, dest, dest)
Transposes a mat4 (flips the values over the diagonal)
|
Method Detail
<static>
{mat4}
mat4.create(mat)
Creates a new instance of a mat4 using the default array type
Any javascript array-like object containing at least 16 numeric elements can serve as a mat4
- Parameters:
- {mat4} mat Optional
- mat4 containing values to initialize with
- Returns:
- {mat4} New mat4
<static>
{number}
mat4.determinant(mat)
Calculates the determinant of a mat4
- Parameters:
- {mat4} mat
- mat4 to calculate determinant of
- Returns:
- {number} determinant of mat
<static>
{mat4}
mat4.frustum(left, right, bottom, top, near, far, dest)
Generates a frustum matrix with the given bounds
- Parameters:
- {number} left
- Left bound of the frustum
- {number} right
- Right bound of the frustum
- {number} bottom
- Bottom bound of the frustum
- {number} top
- Top bound of the frustum
- {number} near
- Near bound of the frustum
- {number} far
- Far bound of the frustum
- {mat4} dest Optional
- mat4 frustum matrix will be written into
- Returns:
- {mat4} dest if specified, a new mat4 otherwise
<static>
{mat4}
mat4.identity(dest)
Sets a mat4 to an identity matrix
- Parameters:
- {mat4} dest
- mat4 to set
- Returns:
- {mat4} dest
<static>
mat4.inverse(mat, dest, dest)
Calculates the inverse matrix of a mat4
- Parameters:
- {mat4} mat
- mat4 to calculate inverse of
- {mat4} dest Optional
- mat4 receiving inverse matrix. If not specified result is written to mat
- {mat4} dest
- is specified, mat otherwise, null if matrix cannot be inverted
<static>
{mat4}
mat4.lookAt(eye, center, up, dest)
Generates a look-at matrix with the given eye position, focal point, and up axis
- Parameters:
- {vec3} eye
- Position of the viewer
- {vec3} center
- Point the viewer is looking at
- {vec3} up
- vec3 pointing "up"
- {mat4} dest Optional
- mat4 frustum matrix will be written into
- Returns:
- {mat4} dest if specified, a new mat4 otherwise
<static>
{mat4}
mat4.multiply(mat, mat2, dest)
Performs a matrix multiplication
- Parameters:
- {mat4} mat
- First operand
- {mat4} mat2
- Second operand
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
{vec3}
mat4.multiplyVec3(mat, vec, dest)
Transforms a vec3 with the given matrix
4th vector component is implicitly '1'
- Parameters:
- {mat4} mat
- mat4 to transform the vector with
- {vec3} vec
- vec3 to transform
- {vec3} dest Optional
- vec3 receiving operation result. If not specified result is written to vec
- Returns:
- {vec3} dest if specified, vec otherwise
<static>
{vec4}
mat4.multiplyVec4(mat, vec, dest)
Transforms a vec4 with the given matrix
- Parameters:
- {mat4} mat
- mat4 to transform the vector with
- {vec4} vec
- vec4 to transform
- {vec4} dest Optional
- vec4 receiving operation result. If not specified result is written to vec
- Returns:
- {vec4} dest if specified, vec otherwise
<static>
{mat4}
mat4.ortho(left, right, bottom, top, near, far, dest)
Generates a orthogonal projection matrix with the given bounds
- Parameters:
- {number} left
- Left bound of the frustum
- {number} right
- Right bound of the frustum
- {number} bottom
- Bottom bound of the frustum
- {number} top
- Top bound of the frustum
- {number} near
- Near bound of the frustum
- {number} far
- Far bound of the frustum
- {mat4} dest Optional
- mat4 frustum matrix will be written into
- Returns:
- {mat4} dest if specified, a new mat4 otherwise
<static>
{mat4}
mat4.perspective(fovy, aspect, near, far, dest)
Generates a perspective projection matrix with the given bounds
- Parameters:
- {number} fovy
- Vertical field of view
- {number} aspect
- Aspect ratio. typically viewport width/height
- {number} near
- Near bound of the frustum
- {number} far
- Far bound of the frustum
- {mat4} dest Optional
- mat4 frustum matrix will be written into
- Returns:
- {mat4} dest if specified, a new mat4 otherwise
<static>
mat4.project(mat, vec, dest)
Project a vec3
- Parameters:
- mat
- vec
- dest
<static>
{mat4}
mat4.rotate(mat, angle, axis, dest)
Rotates a matrix by the given angle around the specified axis
If rotating around a primary axis (X,Y,Z) one of the specialized rotation functions should be used instead for performance
- Parameters:
- {mat4} mat
- mat4 to rotate
- {number} angle
- Angle (in radians) to rotate
- {vec3} axis
- vec3 representing the axis to rotate around
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
mat4.rotateVec3(mat, vec, dest)
mat4.rotateVec3
Rotate a vec3 with the given matrix
Params:
mat - mat4 to transform the vector with
vec - vec3 to transform
dest - Optional, vec3 receiving operation result. If not specified result is written to vec
Returns:
dest if specified, vec otherwise
- Parameters:
- mat
- vec
- dest
<static>
{mat4}
mat4.rotateX(mat, angle, dest)
Rotates a matrix by the given angle around the X axis
- Parameters:
- {mat4} mat
- mat4 to rotate
- {number} angle
- Angle (in radians) to rotate
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
{mat4}
mat4.rotateY(mat, angle, dest)
Rotates a matrix by the given angle around the Y axis
- Parameters:
- {mat4} mat
- mat4 to rotate
- {number} angle
- Angle (in radians) to rotate
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
{mat4}
mat4.rotateZ(mat, angle, dest)
Rotates a matrix by the given angle around the Z axis
- Parameters:
- {mat4} mat
- mat4 to rotate
- {number} angle
- Angle (in radians) to rotate
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
mat4.scale(mat, vec, dest, dest)
Scales a matrix by the given vector
- Parameters:
- {mat4} mat
- mat4 to scale
- {vec3} vec
- vec3 specifying the scale for each axis
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- {mat4} dest
- if specified, mat otherwise
<static>
{mat4}
mat4.set(mat, dest)
Copies the values of one mat4 to another
- Returns:
- {mat4} dest
<static>
{string}
mat4.str(mat)
Returns a string representation of a mat4
- Parameters:
- {mat4} mat
- mat4 to represent as a string
- Returns:
- {string} String representation of mat
<static>
{mat3}
mat4.toMat3(mat, dest)
Copies the upper 3x3 elements of a mat4 into a mat3
- Parameters:
- {mat4} mat
- mat4 containing values to copy
- {mat3} dest Optional
- mat3 receiving copied values
- Returns:
- {mat3} dest is specified, a new mat3 otherwise
<static>
{mat4}
mat4.toRotationMat(mat, dest)
Copies the upper 3x3 elements of a mat4 into another mat4
- Parameters:
- {mat4} mat
- mat4 containing values to copy
- {mat4} dest Optional
- mat4 receiving copied values
- Returns:
- {mat4} dest is specified, a new mat4 otherwise
<static>
{mat4}
mat4.translate(mat, vec, dest)
Translates a matrix by the given vector
- Parameters:
- {mat4} mat
- mat4 to translate
- {vec3} vec
- vec3 specifying the translation
- {mat4} dest Optional
- mat4 receiving operation result. If not specified result is written to mat
- Returns:
- {mat4} dest if specified, mat otherwise
<static>
mat4.transpose(mat, dest, dest)
Transposes a mat4 (flips the values over the diagonal)
- Parameters:
- {mat4} mat
- mat4 to transpose
- {mat4} dest Optional
- mat4 receiving transposed values. If not specified result is written to mat
- {mat4} dest
- is specified, mat otherwise