java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.MassProperties
- All Implemented Interfaces:
ConstJoltPhysicsObject
,ConstMassProperties
,AutoCloseable
,Comparable<JoltPhysicsObject>
The mass and inertial tensor of a
Body
. Used only during
construction.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
decomposePrincipalMomentsOfInertia
(Mat44 storeRotation, Vec3 storeDiagonal) Decompose the inertia tensor into a diagonal matrix and a right-handed rotation matrix.Copy the inertia tensor.float
getMass()
Return the mass.void
Rotate the inertia by the specified 3x3 matrix.void
Scale the mass and inertia by the specified factors.void
scaleToMass
(float mass) Set the mass and scale the inertia tensor to match.setInertia
(Mat44Arg inertia) Alter the inertia tensor.setMass
(float mass) Alter the mass.void
setMassAndInertiaOfSolidBox
(Vec3Arg boxSize, float density) Alter the mass and inertia to that of a box with the specified dimensions and uniform density.toString()
Return a string representation of the properties object, which is unaffected.void
Translate the inertia by the specified offset.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
-
MassProperties
public MassProperties()Instantiate default properties.
-
-
Method Details
-
rotate
Rotate the inertia by the specified 3x3 matrix.- Parameters:
rotation
- the rotation to apply (not null, unaffected)
-
scale
Scale the mass and inertia by the specified factors. Note that factors can be <0 to flip the shape.- Parameters:
scaleFactors
- the desired scaling (not null unaffected)
-
scaleToMass
public void scaleToMass(float mass) Set the mass and scale the inertia tensor to match.- Parameters:
mass
- the desired mass (in kilograms, ≥0)
-
setInertia
Alter the inertia tensor. (native attribute: mInertia)- Parameters:
inertia
- the desired value (not null, unaffected, default=zero)- Returns:
- the modified properties, for chaining
-
setMass
Alter the mass. (native attribute: mMass)- Parameters:
mass
- the desired mass (in kilograms, ≥0, default=0)- Returns:
- the modified properties, for chaining
-
setMassAndInertiaOfSolidBox
Alter the mass and inertia to that of a box with the specified dimensions and uniform density.- Parameters:
boxSize
- the edge lengths of the box (not null, unaffected)density
- the density to use
-
translate
Translate the inertia by the specified offset.- Parameters:
offset
- the amount of translation (not null, unaffected)
-
decomposePrincipalMomentsOfInertia
Decompose the inertia tensor into a diagonal matrix and a right-handed rotation matrix. The properties are unaffected.- Specified by:
decomposePrincipalMomentsOfInertia
in interfaceConstMassProperties
- Parameters:
storeRotation
- storage for the rotation matrix (not null, modified)storeDiagonal
- storage for the diagonal matrix (not null, modified)- Returns:
true
if successful, otherwisefalse
-
getInertia
Copy the inertia tensor. The properties are unaffected. (native attribute: mInertia)- Specified by:
getInertia
in interfaceConstMassProperties
- Returns:
- a new matrix (in kilogram.meters squared)
-
getMass
public float getMass()Return the mass. The properties are unaffected. (native attribute: mMass)- Specified by:
getMass
in interfaceConstMassProperties
- Returns:
- the mass (in kilograms, ≥0)
-
toString
Return a string representation of the properties object, which is unaffected.- Overrides:
toString
in classJoltPhysicsObject
- Returns:
- the string representation (not null, not empty)
-