Package com.github.stephengold.joltjni
Class MassProperties
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.MassProperties
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstMassProperties,AutoCloseable,Comparable<ConstJoltPhysicsObject>
The mass and inertial tensor of a
Body. Used only during
construction.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandecomposePrincipalMomentsOfInertia(Mat44 storeRotation, Vec3 storeDiagonal) Decompose the inertia tensor into a diagonal matrix and a right-handed rotation matrix.Copy the inertia tensor.floatgetMass()Return the mass.voidRotate the inertia by the specified 3x3 matrix.voidScale the mass and inertia by the specified factors.voidscaleToMass(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.toString()Return a string representation of the properties object, which is unaffected.voidTranslate the inertia by the specified offset.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, va
-
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: mIntertia)- 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)
-
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:
decomposePrincipalMomentsOfInertiain interfaceConstMassProperties- Parameters:
storeRotation- storage for the rotation matrix (not null, modified)storeDiagonal- storage for the diagonal matrix (not null, modified)- Returns:
- true if successful, otherwise false
-
getInertia
Copy the inertia tensor. The properties are unaffected. (native attribute: mIntertia)- Specified by:
getInertiain 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:
getMassin interfaceConstMassProperties- Returns:
- the mass (in kilograms, ≥0)
-
toString
Return a string representation of the properties object, which is unaffected.- Overrides:
toStringin classJoltPhysicsObject- Returns:
- the string representation (not null, not empty)
-