kick.math.Mat4 Class
mat4 - 4x4 Matrix
Any javascript array containing at least 16 numeric elements can serve as a Mat4
Item Index
Methods
- adjoint static
- clone static
- copy static
- create static
- decompose static
- determinant static
- fromQuat static
- fromRotationTranslation static
- frustum static
- identity static
- invert static
- lookAt static
- multiply static
- multiplyVec3 static
- multiplyVec3Vector static
- multiplyVec4 static
- ortho static
- perspective static
- rotate static
- rotateX static
- rotateY static
- rotateZ static
- scale static
- setTRS static
- setTRSInverse static
- str static
- strPretty static
- toInverseMat3 static
- toMat3 static
- toNormalMat3 static
- toRotationMat static
- translate static
- transpose static
Methods
adjoint
-
out
-
a
Calculates the adjugate of a mat4
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the source matrix
Returns:
out
clone
-
a
Creates a new mat4 initialized with values from an existing matrix
Parameters:
-
a
kick.math.Mat4matrix to clone
Returns:
a new 4x4 matrix
copy
-
out
-
a
Copies the values of one mat4 to another
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the source matrix
Returns:
out
create
()
kick.math.Mat4
static
Creates a new identity Mat4 using the Float32Arrat
Returns:
New mat4
decompose
-
mat
-
translate
-
rotate
-
scale
Returns array with translate, rotate scale
Parameters:
-
mat
kick.math.Mat4mat4 to decompose
-
translate
kick.math.Vec3 -
rotate
kick.math.Quat -
scale
kick.math.Vec3
Returns:
Array_tranlate_rotate_scale
determinant
-
a
Calculates the determinant of a mat4
Parameters:
-
a
kick.math.Mat4mat4 to calculate determinant of
Returns:
determinant of mat
fromQuat
-
out
-
q
Calculates a 4x4 matrix from the given quaternion
Parameters:
-
out
kick.math.Mat4mat4 receiving operation result
-
q
kick.math.QuatQuaternion to create matrix from
Returns:
out
fromRotationTranslation
-
out
-
q
-
v
mat4.fromRotationTranslation 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);
var quatMat = mat4.create();
quat.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
Parameters:
-
out
kick.math.Mat4mat4 receiving operation result
-
q
kick.math.QuatRotation quaternion
-
v
kick.math.Vec3Translation vector
Returns:
out
frustum
-
out
-
left
-
right
-
bottom
-
top
-
near
-
far
Generates a frustum matrix with the given bounds
Parameters:
-
out
kick.math.Mat4mat4 frustum matrix will be written into
-
left
NumberLeft bound of the frustum
-
right
NumberRight bound of the frustum
-
bottom
NumberBottom bound of the frustum
-
top
NumberTop bound of the frustum
-
near
NumberNear bound of the frustum
-
far
NumberFar bound of the frustum
Returns:
out
identity
-
out
Sets a mat4 to an identity matrix
Parameters:
-
out
kick.math.Mat4mat4 to set
Returns:
out
invert
-
out
-
a
Inverts a Mat4
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the source matrix
Returns:
out
lookAt
-
out
-
eye
-
center
-
up
Generates a look-at matrix with the given eye position, focal point, and up axis
Parameters:
-
out
kick.math.Mat4mat4 frustum matrix will be written into
-
eye
kick.math.Vec3Position of the viewer
-
center
kick.math.Vec3Point the viewer is looking at
-
up
kick.math.Vec3vec3 pointing up
Returns:
out
multiply
-
out
-
a
-
b
Performs a matrix multiplication
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the first operand
-
b
kick.math.Mat4the second operand
Returns:
out
multiplyVec3
-
out
-
mat
-
vec
Transforms a vec3 with the given matrix
4th vector component is implicitly '1'
Parameters:
-
out
kick.math.Vec3vec3 receiving operation result.
-
mat
kick.math.Mat4mat4 to transform the vector with
-
vec
kick.math.Vec3vec3 to transform
Returns:
out
multiplyVec3Vector
-
out
-
mat
-
vec
Transforms a vec3 with the given matrix
4th vector component is implicitly '0'
Parameters:
-
out
kick.math.Vec3vec3 receiving operation result.
-
mat
kick.math.Mat4mat4 to transform the vector with
-
vec
kick.math.Vec3vec3 to transform
Returns:
out
multiplyVec4
-
out
-
mat
-
vec
Transforms a vec4 with the given matrix
Parameters:
-
out
kick.math.Vec4vec4 receiving operation result.
-
mat
kick.math.Mat4mat4 to transform the vector with
-
vec
kick.math.Vec4vec4 to transform
Returns:
out
ortho
-
out
-
left
-
right
-
bottom
-
top
-
near
-
far
Generates a orthogonal projection matrix with the given bounds
Parameters:
-
out
kick.math.Mat4mat4 frustum matrix will be written into
-
left
NumberLeft bound of the frustum
-
right
NumberRight bound of the frustum
-
bottom
NumberBottom bound of the frustum
-
top
NumberTop bound of the frustum
-
near
NumberNear bound of the frustum
-
far
NumberFar bound of the frustum
Returns:
out
perspective
-
out
-
fovy
-
aspect
-
near
-
far
Generates a perspective projection matrix with the given bounds
Parameters:
-
out
kick.math.Mat4mat4 frustum matrix will be written into
-
fovy
NumberVertical field of view in radians
-
aspect
NumberAspect ratio. typically viewport width/height
-
near
NumberNear bound of the frustum
-
far
NumberFar bound of the frustum
Returns:
out
rotate
-
out
-
a
-
rad
-
axis
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:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to rotate
-
rad
Numberthe angle to rotate the matrix by
-
axis
kick.math.Vec3the axis to rotate around
Returns:
out
rotateX
-
out
-
a
-
rad
Rotates a matrix by the given angle around the X axis
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to rotate
-
rad
Numberthe angle to rotate the matrix by
Returns:
out
rotateY
-
out
-
a
-
rad
Rotates a matrix by the given angle around the Y axis
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to rotate
-
rad
Numberthe angle to rotate the matrix by
Returns:
out
rotateZ
-
out
-
a
-
rad
Rotates a matrix by the given angle around the Z axis
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to rotate
-
rad
Numberthe angle to rotate the matrix by
Returns:
out
scale
-
out
-
a
-
v
Scales a matrix by the given vector
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to scale
-
v
kick.math.Vec3the vec3 to scale the matrix by
Returns:
out
setTRS
-
dest
-
translate
-
rotateQuat
-
scale
Set translate, rotate, scale
Parameters:
-
dest
kick.math.Mat4 -
translate
kick.math.Vec3 -
rotateQuat
kick.math.Quat -
scale
kick.math.Vec3
Returns:
dest
setTRSInverse
-
out
-
translate
-
rotateQuat
-
scale
Set the inverse of translate, rotate, scale
Parameters:
-
out
kick.math.Mat4 -
translate
kick.math.Vec3 -
rotateQuat
kick.math.Quatmust be normalized
-
scale
kick.math.Vec3
Returns:
out
str
-
mat
Returns a string representation of a mat4
Parameters:
-
mat
kick.math.Mat4mat4 to represent as a string
Returns:
string representation of mat
strPretty
-
mat
Returns a string representation of a mat4 printed as a 4x4 matrix (on 4 lines)
Parameters:
-
mat
kick.math.Mat4mat4 to represent as a string
Returns:
string representation of mat
toInverseMat3
-
mat
-
out
Calculates the inverse of the upper 3x3 elements of a mat4 and copies the result into a mat3
The resulting matrix is useful for calculating transformed normals
Parameters:
-
mat
kick.math.Mat4mat4 containing values to invert and copy
-
out
kick.math.Mat3mat3 receiving values
Returns:
out
toMat3
-
out
-
mat
Copies the upper 3x3 elements of a mat4 into a mat3
Parameters:
-
out
kick.math.Mat3Optional, mat3 receiving copied values
-
mat
kick.math.Mat4mat4 containing values to copy
Returns:
out
toNormalMat3
-
out
-
mat
Calculates the normal matrix (that is the transpose of the inverse of the upper 3x3 elements of a mat4) and
copies the result into a mat3
Parameters:
-
out
kick.math.Mat3mat3 receiving values
-
mat
kick.math.Mat4mat4 containing values to transpose, invert and copy
Returns:
out
toRotationMat
-
out
-
mat
Copies the upper 3x3 elements of a mat4 into another mat4
Parameters:
-
out
kick.math.Mat4mat4 receiving copied values
-
mat
kick.math.Mat4mat4 containing values to copy
Returns:
out
translate
-
out
-
a
-
v
Translates a matrix by the given vector
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the matrix to translate
-
v
kick.math.Vec3vector to translate by
Returns:
out
transpose
-
out
-
a
Transposes a mat4 (flips the values over the diagonal)
Parameters:
-
out
kick.math.Mat4the receiving matrix
-
a
kick.math.Mat4the source matrix
Returns:
out