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

Matrix4(@NonNull float[] dataToCopy)

Creates a new matrix with a deep copy of the data from the other.

Public methods

final @NonNull Matrix4
copy(@NonNull float[] data)

Returns a copy of the matrix.

boolean
equals(Object other)

Returns true if this pose is equal to other.

static final @NonNull Matrix4

Returns a new rigid transformation matrix.

static final @NonNull Matrix4

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

Returns a new translation matrix.

static final @NonNull Matrix4
fromTrs(
    @NonNull Vector3 translation,
    @NonNull Quaternion rotation,
    @NonNull Vector3 scale
)

Returns a new transformation matrix.

final @NonNull float[]

Returns an array of the components of this matrix.

final @NonNull Matrix4

Returns a matrix that performs the opposite transformation.

final @NonNull Pose

Returns the pose (i.e. rotation and translation) of this matrix.

final @NonNull Quaternion

Returns the rotation component of this matrix.

final @NonNull Vector3

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

Standard hash code calculation using constructor values

final boolean

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 other matrix.

@NonNull String

Standard toString() implementation

Public fields

Identity

public static final @NonNull Matrix4 Identity

Returns an identity matrix.

Zero

public static final @NonNull Matrix4 Zero

Returns a zero matrix.

Public constructors

Matrix4

Added in 1.0.0-alpha01
public Matrix4(@NonNull float[] dataToCopy)
Parameters
@NonNull float[] dataToCopy

the array with 16 elements that will be copied over.

Matrix4

Added in 1.0.0-alpha01
public Matrix4(@NonNull Matrix4 other)

Creates a new matrix with a deep copy of the data from the other.

Public methods

copy

Added in 1.0.0-alpha01
public final @NonNull Matrix4 copy(@NonNull float[] data)

Returns a copy of the matrix.

equals

public boolean equals(Object other)

Returns true if this pose is equal to other.

fromPose

Added in 1.0.0-alpha01
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

Added in 1.0.0-alpha01
public static final @NonNull Matrix4 fromQuaternion(@NonNull Quaternion quaternion)

Returns a new rotation matrix.

fromScale

Added in 1.0.0-alpha01
public static final @NonNull Matrix4 fromScale(float scale)

Returns a new scale matrix.

fromScale

Added in 1.0.0-alpha01
public static final @NonNull Matrix4 fromScale(@NonNull Vector3 scale)

Returns a new uniform scale matrix.

fromTranslation

Added in 1.0.0-alpha01
public static final @NonNull Matrix4 fromTranslation(@NonNull Vector3 translation)

Returns a new translation matrix.

fromTrs

Added in 1.0.0-alpha01
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

Added in 1.0.0-alpha01
public final @NonNull float[] getData()

Returns an array of the components of this matrix.

getInverse

Added in 1.0.0-alpha01
public final @NonNull Matrix4 getInverse()

Returns a matrix that performs the opposite transformation.

getPose

Added in 1.0.0-alpha01
public final @NonNull Pose getPose()

Returns the pose (i.e. rotation and translation) of this matrix.

getRotation

Added in 1.0.0-alpha01
public final @NonNull Quaternion getRotation()

Returns the rotation component of this matrix.

getScale

Added in 1.0.0-alpha01
public final @NonNull Vector3 getScale()

Returns the scale component of this matrix.

getTranslation

Added in 1.0.0-alpha01
public final @NonNull Vector3 getTranslation()

Returns the translation component of this matrix.

getTranspose

Added in 1.0.0-alpha01
public final @NonNull Matrix4 getTranspose()

Returns a matrix that is the transpose of this matrix.

hashCode

public int hashCode()

Standard hash code calculation using constructor values

isTrs

Added in 1.0.0-alpha01
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

Added in 1.0.0-alpha01
public final @NonNull Matrix4 times(@NonNull Matrix4 other)

Returns a new matrix with the matrix multiplication product of this matrix and the other matrix.

toString

public @NonNull String toString()

Standard toString() implementation