Matrix4
class Matrix4
An immutable 4x4 matrix that represents translation, scale, and rotation. The matrix is column major and right handed. The indexes of dataToCopy represent the following matrix layout:
[0, 4, 8, 12]
[1, 5, 9, 13]
[2, 6, 10, 14]
[3, 7, 11, 15]
Summary
Public companion functions |
|
|---|---|
Matrix4 |
Returns a new rigid transformation matrix. |
Matrix4 |
fromQuaternion(quaternion: Quaternion)Returns a new rotation matrix. |
Matrix4 |
Returns a new scale matrix. |
Matrix4 |
Returns a new uniform scale matrix. |
Matrix4 |
fromTranslation(translation: Vector3)Returns a new translation matrix. |
Matrix4 |
fromTrs(translation: Vector3, rotation: Quaternion, scale: Vector3)Returns a new transformation matrix. |
Public constructors |
|---|
Matrix4(dataToCopy: FloatArray) |
|
Creates a new matrix with a deep copy of the data from the |
Public functions |
|
|---|---|
Matrix4 |
copy(data: FloatArray)Returns a copy of the matrix. |
open operator Boolean |
Returns true if this pose is equal to |
open Int |
hashCode()Standard hash code calculation using constructor values |
operator Matrix4 |
Returns a new matrix with the matrix multiplication product of this matrix and the |
open String |
toString()Standard toString() implementation |
Matrix4 |
unscaled()Returns a normalized transformation matrix. |
Public properties |
|
|---|---|
FloatArray |
Returns an array of the components of this matrix. |
Matrix4 |
Returns a matrix that performs the opposite transformation. |
Boolean |
Returns true if this matrix is a valid transformation matrix that can be decomposed into translation, rotation and scale using determinant properties. |
Pose |
Returns the pose (i.e. rotation and translation) of this matrix. |
Quaternion |
Returns the rotation component of this matrix. |
Vector3 |
Returns the scale component of this matrix. |
Vector3 |
Returns the translation component of this matrix. |
Matrix4 |
Returns a matrix that is the transpose of this matrix. |
Public companion functions
fromPose
fun fromPose(pose: Pose): Matrix4
Returns a new rigid transformation matrix. The returned matrix is such that it first rotates objects, and then translates them.
fromQuaternion
fun fromQuaternion(quaternion: Quaternion): Matrix4
Returns a new rotation matrix.
fromScale
fun fromScale(scale: Vector3): Matrix4
Returns a new uniform scale matrix.
fromTranslation
fun fromTranslation(translation: Vector3): Matrix4
Returns a new translation matrix.
fromTrs
fun fromTrs(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4
Returns a new transformation matrix. The returned matrix is such that it first scales objects, then rotates them, and finally translates them.
Public companion properties
Public constructors
Matrix4
Matrix4(dataToCopy: FloatArray)
| Parameters | |
|---|---|
dataToCopy: FloatArray |
the array with 16 elements that will be copied over. |
Matrix4
Matrix4(other: Matrix4)
Creates a new matrix with a deep copy of the data from the other.
Public functions
copy
fun copy(data: FloatArray = this.data): Matrix4
Returns a copy of the matrix.
times
operator fun times(other: Matrix4): Matrix4
Returns a new matrix with the matrix multiplication product of this matrix and the other matrix.
unscaled
fun unscaled(): Matrix4
Returns a normalized transformation matrix.
This method removes the scaling factors from this matrix, as determined by scale, while preserving its core rotational and translational components. The resulting matrix is therefore ideal for accurate normal vector transformations and pure orientation extraction.
Public properties
inverse
val inverse: Matrix4
Returns a matrix that performs the opposite transformation.
isTrs
val isTrs: Boolean
Returns true if this matrix is a valid transformation matrix that can be decomposed into translation, rotation and scale using determinant properties.
pose
val pose: Pose
Returns the pose (i.e. rotation and translation) of this matrix.
rotation
val rotation: Quaternion
Returns the rotation component of this matrix.
translation
val translation: Vector3
Returns the translation component of this matrix.
transpose
val transpose: Matrix4
Returns a matrix that is the transpose of this matrix.