Matrix4
public final 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 fields |
|
|---|---|
static final @NonNull Matrix4 |
Returns an identity matrix. |
static final @NonNull Matrix4 |
Returns a zero matrix. |
Public constructors |
|---|
|
Creates a new matrix with a deep copy of the data from the |
Public methods |
|
|---|---|
final @NonNull Matrix4 |
Returns a copy of the matrix. |
boolean |
Returns true if this pose is equal to |
static final @NonNull Matrix4 |
Returns a new rigid transformation matrix. |
static final @NonNull Matrix4 |
fromQuaternion(@NonNull Quaternion quaternion)Returns a new rotation matrix. |
static final @NonNull Matrix4 |
fromScale(float scale)Returns a new scale matrix. |
static final @NonNull Matrix4 |
Returns a new uniform scale matrix. |
static final @NonNull Matrix4 |
fromTranslation(@NonNull Vector3 translation)Returns a new translation matrix. |
static final @NonNull Matrix4 |
Returns a new transformation matrix. |
final @NonNull float[] |
getData()Returns an array of the components of this matrix. |
final @NonNull Matrix4 |
Returns a matrix that performs the opposite transformation. |
final @NonNull Pose |
getPose()Returns the pose (i.e. rotation and translation) of this matrix. |
final @NonNull Quaternion |
Returns the rotation component of this matrix. |
final @NonNull Vector3 |
getScale()Returns the scale component of this matrix. |
final @NonNull Vector3 |
Returns the translation component of this matrix. |
final @NonNull Matrix4 |
Returns a matrix that is the transpose of this matrix. |
int |
hashCode()Standard hash code calculation using constructor values |
final boolean |
isTrs()Returns true if this matrix is a valid transformation matrix that can be decomposed into translation, rotation and scale using determinant properties. |
final @NonNull Matrix4 |
Returns a new matrix with the matrix multiplication product of this matrix and the |
@NonNull String |
toString()Standard toString() implementation |
final @NonNull Matrix4 |
unscaled()Returns a normalized transformation matrix. |
Public fields
Public constructors
Matrix4
public Matrix4(@NonNull float[] dataToCopy)
| Parameters | |
|---|---|
@NonNull float[] dataToCopy |
the array with 16 elements that will be copied over. |
Matrix4
public Matrix4(@NonNull Matrix4 other)
Creates a new matrix with a deep copy of the data from the other.
Public methods
copy
public final @NonNull Matrix4 copy(@NonNull float[] data)
Returns a copy of the matrix.
fromPose
public static final @NonNull Matrix4 fromPose(@NonNull Pose pose)
Returns a new rigid transformation matrix. The returned matrix is such that it first rotates objects, and then translates them.
fromQuaternion
public static final @NonNull Matrix4 fromQuaternion(@NonNull Quaternion quaternion)
Returns a new rotation matrix.
fromScale
public static final @NonNull Matrix4 fromScale(float scale)
Returns a new scale matrix.
fromScale
public static final @NonNull Matrix4 fromScale(@NonNull Vector3 scale)
Returns a new uniform scale matrix.
fromTranslation
public static final @NonNull Matrix4 fromTranslation(@NonNull Vector3 translation)
Returns a new translation matrix.
fromTrs
public static final @NonNull Matrix4 fromTrs(
@NonNull Vector3 translation,
@NonNull Quaternion rotation,
@NonNull Vector3 scale
)
Returns a new transformation matrix. The returned matrix is such that it first scales objects, then rotates them, and finally translates them.
getData
public final @NonNull float[] getData()
Returns an array of the components of this matrix.
getInverse
public final @NonNull Matrix4 getInverse()
Returns a matrix that performs the opposite transformation.
getPose
public final @NonNull Pose getPose()
Returns the pose (i.e. rotation and translation) of this matrix.
getRotation
public final @NonNull Quaternion getRotation()
Returns the rotation component of this matrix.
getScale
public final @NonNull Vector3 getScale()
Returns the scale component of this matrix.
getTranslation
public final @NonNull Vector3 getTranslation()
Returns the translation component of this matrix.
getTranspose
public final @NonNull Matrix4 getTranspose()
Returns a matrix that is the transpose of this matrix.
isTrs
public final boolean isTrs()
Returns true if this matrix is a valid transformation matrix that can be decomposed into translation, rotation and scale using determinant properties.
times
public final @NonNull Matrix4 times(@NonNull Matrix4 other)
Returns a new matrix with the matrix multiplication product of this matrix and the other matrix.
unscaled
public final @NonNull Matrix4 unscaled()
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.