new Matrix4x4()
Members
-
lookAt
-
Initializes as a "lookAt" matrix at the given eye position oriented toward a target
-
<static> IDENTITY
-
Preset for the identity matrix
-
<static> ZERO
-
Preset for the all-zero matrix
Methods
-
add()
-
Adds the elements of another matrix to this one.
-
addAffine()
-
Adds the elements of another matrix to this one, assuming both are affine.
-
append()
-
Post-multiplication (M x this)
-
appendAffine()
-
Post-multiplication (M x this) assuming affine matrices
-
appendQuaternion()
-
Post-multiplies a quaternion rotation
-
appendRotationAxisAngle()
-
Post-multiplies an axis/angle rotation
-
appendScale()
-
Post-multiplies a scale
-
appendTranslation()
-
Post-multiplies a translation
-
clone()
-
Returns a copy of this object.
-
cofactor()
-
Calculates the cofactor for the given row and column
-
compose()
-
Initializes as an affine transformation based on a transform object
-
copyColumn(index, m)
-
Copies a column from another matrix.
Parameters:
Name Type Description indexNumber The index of the column.
mMatrix4x4 The matrix from which to copy.
-
copyFrom()
-
Copies its elements from another matrix.
-
decompose(targetOrPos, quat, quat)
-
Decomposes an affine transformation matrix into a Transform object, or a triplet position, quaternion, scale.
Parameters:
Name Type Description targetOrPosAn optional target object to store the values. If this is a Float4, quat and scale need to be provided. If omitted, a new Transform object will be created and returned.
quatAn optional quaternion to store rotation. Unused if targetOrPos is a Transform object.
quatAn optional Float4 to store scale. Unused if targetOrPos is a Transform object.
-
determinant()
-
Calculates the determinant of the matrix.
-
fromEuler()
-
Initializes the matrix as a rotation matrix from 3 Euler angles
-
fromOrthographicOffCenterProjection(left, right, top, bottom, nearDistance, farDistance)
-
Initializes as an off-center orthographic projection matrix.
Parameters:
Name Type Description leftThe distance to the left plane
rightThe distance to the right plane
topThe distance to the top plane
bottomThe distance to the bottom plane
nearDistanceThe near plane distance
farDistanceThe far plane distance
-
fromOrthographicProjection(width, top, nearDistance, farDistance)
-
Initializes as a symmetrical orthographic projection matrix.
Parameters:
Name Type Description widthThe width of the projection
topThe height of the projection
nearDistanceThe near plane distance
farDistanceThe far plane distance
-
fromPerspectiveProjection(vFOV, aspectRatio, nearDistance, farDistance)
-
Initializes as a perspective projection matrix (from right-handed Y-up to left-handed NDC!).
Parameters:
Name Type Description vFOVThe vertical field of view in radians.
aspectRatioThe aspect ratio
nearDistanceThe near plane distance
farDistanceThe far plane distance
-
fromQuaternion()
-
Initializes the matrix as a rotation matrix based on a quaternion.
-
fromRotationAxisAngle(axis, radians)
-
Initializes the matrix as a rotation matrix around a given axis
Parameters:
Name Type Description axisThe axis around which the rotation takes place.
radiansThe angle of rotation
-
fromRotationPitchYawRoll()
-
Initializes the matrix as a rotation matrix from Tait-Bryan angles (pitch, yaw, roll).
-
fromScale(x, y, z)
-
Initializes as a scale matrix.
Parameters:
Name Type Description xyz -
fromTranslation(xOrV, y, z)
-
Initializes as a translation matrix.
Parameters:
Name Type Description xOrVA Float4 or a Number as x-coordinate
yThe y-translation. Omitted if xOrV is a Float4.
zThe z-translation. Omitted if xOrV is a Float4.
-
getAdjugate()
-
Calculates teh adjugate matrix.
-
getCofactorMatrix()
-
Creates a matrix containing all the cofactors.
-
getColumn(index [, target])
-
Gets the given column from the matrix.
Parameters:
Name Type Argument Description indexNumber The index of the column
targetFloat4 <optional>
An optional target. If omitted, a new object will be created.
-
getElement(row, col)
-
Gets the value of a single element.
Parameters:
Name Type Description rowThe row index
colThe column index
-
getRow(index [, target])
-
Gets the given row from the matrix.
Parameters:
Name Type Argument Description indexNumber The index of the row
targetFloat4 <optional>
An optional target. If omitted, a new object will be created.
-
inverseAffineOf()
-
Initializes as the inverse of the given matrix, assuming it is affine. It's faster than regular inverse. If the matrix is not invertible, the method returns null and the matrix remains unchanged.
-
inverseOf()
-
Initializes as the inverse of the given matrix. If the matrix is not invertible, the method returns null and the matrix remains unchanged. Otherwise, it returns itself.
-
invert()
-
Inverts the matrix. If the matrix is not invertible, the method returns null and the matrix remains unchanged. Otherwise, it returns itself.
-
invertAffine()
-
Inverts the matrix, assuming it's affine (faster than regular inverse). If the matrix is not invertible, the method returns null and the matrix remains unchanged. Otherwise, it returns itself.
-
multiply(a, b)
-
Multiplies two matrix objects and stores the result in this one
Parameters:
Name Type Description ab -
multiplyAffine(a, b)
-
Multiplies two matrix objects, assuming they're affine transformations, and stores the result in this one
Parameters:
Name Type Description ab -
prepend()
-
Pre-multiplication (this x M)
-
prependAffine()
-
Pre-multiplication (M x this) assuming affine matrices
-
prependQuaternion()
-
Pre-multiplies a quaternion rotation
-
prependRotationAxisAngle()
-
Pre-multiplies an axis/angle rotation
-
prependScale()
-
Pre-multiplies a scale
-
prependTranslation()
-
Pre-multiplies a translation
-
projectPoint(v [, target])
-
Transforms a Float4 point (assuming its w component is 1) and divides by the resulting w
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
set()
-
Sets the values of the matrix directly.
-
setColumn(index, v)
-
Sets a column in the matrix.
Parameters:
Name Type Description indexNumber The index of the column.
vFloat4 The vector to assign to the column
-
setElement(row, col, value)
-
Sets the value of a single element.
Parameters:
Name Type Description rowThe row index
colThe column index
valueThe value to assign to the element
-
setRow(index, v)
-
Sets a row in the matrix.
Parameters:
Name Type Description indexNumber The index of the row.
vFloat4 The vector to assign to the row
-
subtract()
-
Subtracts the elements of another matrix from this one.
-
subtractAffine()
-
Subtracts the elements of another matrix from this one, assuming both are affine.
-
swapColums()
-
Swaps two columns
-
transform(v [, target])
-
Transforms a Float4 object (use for homogeneous general case of Float4, perspective or when "type" (w) of Float4 is unknown)
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
transformExtent(v [, target])
-
Transforms a Float4 object, treating it as a vector (ie: disregarding translation) containing a size (so always abs)! Slightly faster than transform for vectors.
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
transformNormal(v [, target])
-
Transforms a Float4 object, treating it as a normal vector.
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
transformPoint(v [, target])
-
Transforms a Float4 object, treating it as a point. Slightly faster than transform for points.
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
transformQuaternion(q [, target])
-
Transforms a Quaternion.
Parameters:
Name Type Argument Description qQuaternion The quaternion to transform
targetQuaternion <optional>
An optional target. If not provided, a new object will be created and returned.
-
transformVector(v [, target])
-
Transforms a Float4 object, treating it as a vector (ie: disregarding translation). Slightly faster than transform for vectors.
Parameters:
Name Type Argument Description vThe Float4 object to transform.
target<optional>
An optional target. If not provided, a new object will be created and returned.
-
transpose()
-
Transposes the matrix.
-
writeData()
-
Writes the matrix into an array for upload
-
writeData4x3()
-
Writes the matrix into an array for upload, ignoring the bottom row (for affine matrices)
-
writeNormalMatrix()
-
Writes the inverse transpose into an array for upload (must support 9 elements)
-
<static> add()
-
Adds two matrices together
-
<static> multiply()
-
Multiplies two matrices. The order of the parameters are the order of the multiplication. M1 is appended to M2