Matrix3


public final class Matrix3


An immutable 3x3 matrix that represents rotation and scale. The matrix is column major and right handed. The indexes of dataToCopy represent the following matrix layout:

[0, 3, 6]
[1, 4, 7]
[2, 5, 8]

Summary

Public fields

static final @NonNull Matrix3

Returns an identity matrix.

static final @NonNull Matrix3

Returns a zero matrix.

Public constructors

Matrix3(@NonNull float[] dataToCopy)

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

Public methods

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

Returns a copy of the matrix.

boolean
equals(Object other)

Returns true if this matrix is equal to other.

static final @NonNull Matrix3

Returns a new 3x3 rotation matrix from the given quaternion, which is first normalized.

static final @NonNull Matrix3
fromScale(float scale)

Returns a new uniform scale matrix.

static final @NonNull Matrix3

Returns a new scale matrix.

final @NonNull float[]

Returns an array of the components of this matrix.

final @NonNull Matrix3

Returns a matrix that performs the opposite transformation.

final @NonNull Quaternion

Returns the rotation component of this matrix.

final @NonNull Vector3

Returns the scale component of this matrix.

final @NonNull Matrix3

Returns a matrix that is the transpose of this matrix.

int

Standard hash code calculation using constructor values.

final boolean

True if the matrix represents a valid rotation-scale transformation.

final @NonNull Matrix3

Multiplies this matrix by other.

@NonNull String

Standard toString() implementation.

Public fields

IDENTITY

public static final @NonNull Matrix3 IDENTITY

Returns an identity matrix.

ZERO

public static final @NonNull Matrix3 ZERO

Returns a zero matrix.

Public constructors

Matrix3

Added in 1.0.0
public Matrix3(@NonNull float[] dataToCopy)
Parameters
@NonNull float[] dataToCopy

the array with 9 elements that will be copied over

Matrix3

Added in 1.0.0
public Matrix3(@NonNull Matrix3 other)

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

Public methods

copy

Added in 1.0.0
public final @NonNull Matrix3 copy(@NonNull float[] data)

Returns a copy of the matrix.

Parameters
@NonNull float[] data

the new data for the copied matrix

equals

public boolean equals(Object other)

Returns true if this matrix is equal to other.

fromQuaternion

Added in 1.0.0
public static final @NonNull Matrix3 fromQuaternion(@NonNull Quaternion quaternion)

Returns a new 3x3 rotation matrix from the given quaternion, which is first normalized. This function uses a standard formula for the conversion, though alternative algebraic expressions exist due to differing conventions. The resulting matrix typically transforms 3D column vectors by pre-multiplication (e.g.,

$v'_{new} = M \cdot v_{old}$

).

Parameters
@NonNull Quaternion quaternion

the quaternion to convert

fromScale

Added in 1.0.0
public static final @NonNull Matrix3 fromScale(float scale)

Returns a new uniform scale matrix.

Parameters
float scale

the uniform scale factor

fromScale

Added in 1.0.0
public static final @NonNull Matrix3 fromScale(@NonNull Vector3 scale)

Returns a new scale matrix.

Parameters
@NonNull Vector3 scale

the scale vector

getData

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

Returns an array of the components of this matrix.

getInverse

Added in 1.0.0
public final @NonNull Matrix3 getInverse()

Returns a matrix that performs the opposite transformation.

getRotation

Added in 1.0.0
public final @NonNull Quaternion getRotation()

Returns the rotation component of this matrix.

getScale

Added in 1.0.0
public final @NonNull Vector3 getScale()

Returns the scale component of this matrix.

getTranspose

Added in 1.0.0
public final @NonNull Matrix3 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
public final boolean isTrs()

True if the matrix represents a valid rotation-scale transformation.

times

Added in 1.0.0
public final @NonNull Matrix3 times(@NonNull Matrix3 other)

Multiplies this matrix by other.

toString

public @NonNull String toString()

Standard toString() implementation.