java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.RMat44
- All Implemented Interfaces:
ConstJoltPhysicsObject
,RMat44Arg
,AutoCloseable
,Comparable<JoltPhysicsObject>
A 4x4 matrix used to represent transformations of 3-D coordinates.
-
Constructor Summary
ConstructorsConstructorDescriptionRMat44()
Instantiate an uninitialized matrix.Instantiate from a single-precision matrix.Instantiate a copy of the specified matrix.Instantiate a matrix with the specified columns. -
Method Summary
Modifier and TypeMethodDescriptiongetAxisX()
Copy the first column to aVec3
.getAxisY()
Copy the 2nd column to aVec3
.getAxisZ()
Copy the 3rd column to aVec3
.Copy the diagonal elements to aVec3
.double
getElement
(int row, int column) Return the specified element in double precision.Convert the rotation to aQuat
.Copy the translation component.inversed()
Return the inverse of the current matrix, which is unaffected.Return the inverse of the current matrix, assuming the current matrix consists entirely of rotation and translation.boolean
Test whether the current matrix is equal to the argument.boolean
Test whether the current matrix is an identity matrix.void
leftMultiplyInPlace
(RMat44Arg leftFactor) Left-multiply the current matrix by the argument.void
Set the current matrix to identity.Multiply the current matrix by the specified single-precision matrix.Multiply the current matrix by the argument.multiply3x3
(Vec3Arg vec3Arg) Multiply the 3x3 matrix by the specified column vector.multiply3x3Transposed
(Vec3Arg rightVector) Multiply the transpose of the 3x3 matrix by the specified column vector.multiply3x4
(RVec3Arg rightVector) Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one.multiply3x4
(Vec3Arg vec3) Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one.postTranslated
(RVec3Arg leftVector) Post multiply by the specified translation vector.postTranslated
(Vec3Arg vec3) Post multiply by the specified translation vector.static RMat44
Return the product of the specified matrices.void
put3x3ColumnMajor
(FloatBuffer storeBuffer) Write the 3x3 matrix in single precision to the specified buffer in column-major order and advance the buffer's position by 9.void
putColumnMajor
(FloatBuffer storeBuffer) Write all 16 components in single precision to the specified buffer in column-major order and advance the buffer's position by 16.void
rightMultiplyInPlace
(RMat44Arg rightFactor) Right-multiply the current matrix by the argument.void
Copy all elements of the argument to the current matrix.void
Set the first column to the specified vector.void
Set the 2nd column to the specified vector.void
Set the 3rd column to the specified vector.void
setElement
(int row, int column, double value) Alter the specified element in double precision.void
setTranslation
(RVec3Arg offset) Alter the translation component.static RMat44
Create an identity matrix.static RMat44
Create a rotation matrix from the specified quaternion.static RMat44
sRotationTranslation
(QuatArg rotation, RVec3Arg offset) Create a translation-and-rotation matrix.static RMat44
sScale
(float factor) Create a uniform scaling matrix.static RMat44
Create a pure scaling matrix.static RMat44
sTranslation
(RVec3Arg offset) Create a pure translation matrix.static RMat44
sZero()
Create an all-zero matrix.toMat44()
Copy the current matrix to a new, single-precision matrix.toString()
Return a string representation of the matrix, which is unaffected.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
RMat44
public RMat44()Instantiate an uninitialized matrix. -
RMat44
Instantiate from a single-precision matrix.- Parameters:
spMatrix
- the matrix to copy (not null, unaffected)
-
RMat44
Instantiate a copy of the specified matrix.- Parameters:
original
- the matrix to duplicate (not null, unaffected)
-
RMat44
Instantiate a matrix with the specified columns.- Parameters:
c1
- the desired first/leftmost column (not null, unaffected)c2
- the desired 2nd column (not null, unaffected)c3
- the desired 3rd column (not null, unaffected)c4
- the desired 4th/rightmost column (not null, unaffected)
-
-
Method Details
-
leftMultiplyInPlace
Left-multiply the current matrix by the argument.- Parameters:
leftFactor
- the left factor (not null, unaffected)
-
loadIdentity
public void loadIdentity()Set the current matrix to identity. -
product
Return the product of the specified matrices.- Parameters:
mArray
- an array of input matrices (not null, unaffected)- Returns:
- a new matrix
-
rightMultiplyInPlace
Right-multiply the current matrix by the argument.- Parameters:
rightFactor
- the right factor (not null, unaffected)
-
set
Copy all elements of the argument to the current matrix.- Parameters:
source
- the matrix to copy (not null, unaffected)
-
setAxisX
Set the first column to the specified vector.- Parameters:
vec
- the vector to use (not null, unaffected)
-
setAxisY
Set the 2nd column to the specified vector.- Parameters:
vec
- the vector to use (not null, unaffected)
-
setAxisZ
Set the 3rd column to the specified vector.- Parameters:
vec
- the vector to use (not null, unaffected)
-
setElement
public void setElement(int row, int column, double value) Alter the specified element in double precision.- Parameters:
row
- the zero-origin index of the row (≥0, <4)column
- the zero-origin index of the column (≥0, <4)value
- the desired value
-
setTranslation
Alter the translation component.- Parameters:
offset
- the desired translation (not null, unaffected)
-
sIdentity
Create an identity matrix.- Returns:
- a new matrix
-
sRotation
Create a rotation matrix from the specified quaternion.- Parameters:
rotation
- the rotation quaternion to use (not null, unaffected)- Returns:
- a new object
-
sRotationTranslation
Create a translation-and-rotation matrix.- Parameters:
rotation
- the amount to rotate (not null, unaffected)offset
- the amount to translate (not null, unaffected)- Returns:
- a new object
-
sScale
Create a uniform scaling matrix.- Parameters:
factor
- the amount to scale each axis- Returns:
- a new matrix
-
sScale
Create a pure scaling matrix.- Parameters:
factors
- the amount to scale each axis (not null, unaffected)- Returns:
- a new matrix
-
sTranslation
Create a pure translation matrix.- Parameters:
offset
- the amount to translate (not null, unaffected)- Returns:
- a new matrix
-
sZero
Create an all-zero matrix.- Returns:
- a new matrix
-
getAxisX
Copy the first column to aVec3
. The matrix is unaffected. -
getAxisY
Copy the 2nd column to aVec3
. The matrix is unaffected. -
getAxisZ
Copy the 3rd column to aVec3
. The matrix is unaffected. -
getDiagonal3
Copy the diagonal elements to aVec3
. The matrix is unaffected.- Specified by:
getDiagonal3
in interfaceRMat44Arg
- Returns:
- a new vector
-
getElement
public double getElement(int row, int column) Return the specified element in double precision. The matrix is unaffected.- Specified by:
getElement
in interfaceRMat44Arg
- Parameters:
row
- the zero-origin index of the row (≥0, <4)column
- the zero-origin index of the column (≥0, <4)- Returns:
- the element's value
-
getQuaternion
Convert the rotation to aQuat
. The matrix is unaffected.- Specified by:
getQuaternion
in interfaceRMat44Arg
- Returns:
- a new rotation quaternion
-
getTranslation
Copy the translation component. The matrix is unaffected.- Specified by:
getTranslation
in interfaceRMat44Arg
- Returns:
- a new vector
-
inversed
Return the inverse of the current matrix, which is unaffected. -
inversedRotationTranslation
Return the inverse of the current matrix, assuming the current matrix consists entirely of rotation and translation. The current matrix is unaffected.- Specified by:
inversedRotationTranslation
in interfaceRMat44Arg
- Returns:
- a new matrix
-
isEqual
Test whether the current matrix is equal to the argument. The current matrix is unaffected. -
isIdentity
public boolean isIdentity()Test whether the current matrix is an identity matrix. The matrix is unaffected.- Specified by:
isIdentity
in interfaceRMat44Arg
- Returns:
true
if exactly equal, otherwisefalse
-
multiply
Multiply the current matrix by the specified single-precision matrix. The current matrix is unaffected. -
multiply
Multiply the current matrix by the argument. The current matrix is unaffected. -
multiply3x3
Multiply the 3x3 matrix by the specified column vector. The matrix is unaffected.- Specified by:
multiply3x3
in interfaceRMat44Arg
- Parameters:
vec3Arg
- the right factor (not null, unaffected)- Returns:
- a new vector
-
multiply3x3Transposed
Multiply the transpose of the 3x3 matrix by the specified column vector. The matrix is unaffected.- Specified by:
multiply3x3Transposed
in interfaceRMat44Arg
- Parameters:
rightVector
- the right factor (not null, unaffected)- Returns:
- a new vector
-
multiply3x4
Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one. The matrix is unaffected.- Specified by:
multiply3x4
in interfaceRMat44Arg
- Parameters:
rightVector
- the right factor (not null, unaffected)- Returns:
- a new vector
-
multiply3x4
Multiply the 3x4 matrix by the specified column vector, with the 4th component of the right factor implied to be one. The matrix is unaffected.- Specified by:
multiply3x4
in interfaceRMat44Arg
- Parameters:
vec3
- the right factor (not null, unaffected)- Returns:
- a new vector
-
postTranslated
Post multiply by the specified translation vector. The current matrix is unaffected.- Specified by:
postTranslated
in interfaceRMat44Arg
- Parameters:
leftVector
- the left factor (not null, unaffected)- Returns:
- a new matrix
-
postTranslated
Post multiply by the specified translation vector. The current matrix is unaffected.- Specified by:
postTranslated
in interfaceRMat44Arg
- Parameters:
vec3
- the left factor (not null, unaffected)- Returns:
- a new matrix
-
put3x3ColumnMajor
Write the 3x3 matrix in single precision to the specified buffer in column-major order and advance the buffer's position by 9. The matrix is unaffected.- Specified by:
put3x3ColumnMajor
in interfaceRMat44Arg
- Parameters:
storeBuffer
- the destination buffer (not null)
-
putColumnMajor
Write all 16 components in single precision to the specified buffer in column-major order and advance the buffer's position by 16. The matrix is unaffected.- Specified by:
putColumnMajor
in interfaceRMat44Arg
- Parameters:
storeBuffer
- the destination buffer (not null)
-
toMat44
Copy the current matrix to a new, single-precision matrix. The current matrix is unaffected. -
toString
Return a string representation of the matrix, which is unaffected. For example, an identity matrix is represented by:RMat44[ 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 ]
- Overrides:
toString
in classJoltPhysicsObject
- Returns:
- the string representation (not null, not empty)
-