java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.MassProperties
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstMassProperties,AutoCloseable,Comparable<JoltPhysicsObject>
The mass and inertia tensor of a
Body. Used only during construction.-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default properties.MassProperties(ConstMassProperties original) Instantiate a copy of the specified properties. -
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.booleanisEqual(ConstMassProperties other) Test whether this object is equal to the argument.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.voidsetMassAndInertiaOfSolidBox(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.voidTranslate the inertia by the specified offset.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, 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, targetVa
-
Constructor Details
-
MassProperties
public MassProperties()Instantiate default properties. -
MassProperties
Instantiate a copy of the specified properties.- Parameters:
original- the properties to copy (notnull, unaffected)
-
-
Method Details
-
rotate
Rotate the inertia by the specified 3x3 matrix.- Parameters:
rotation- the rotation to apply (notnull, 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 (notnull, 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 (notnull, 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 (notnull, unaffected)density- the density to use
-
translate
Translate the inertia by the specified offset.- Parameters:
offset- the amount of translation (notnull, 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 (notnull, modified)storeDiagonal- storage for the diagonal matrix (notnull, modified)- Returns:
trueif successful, otherwisefalse
-
getInertia
Copy the inertia tensor. The properties are unaffected. (native attribute: mInertia)- Specified by:
getInertiain interfaceConstMassProperties- Returns:
- a new matrix (in kilogram.meters^2)
-
getMass
public float getMass()Return the mass. The properties are unaffected. (native attribute: mMass)- Specified by:
getMassin interfaceConstMassProperties- Returns:
- the mass (in kilograms, ≥0)
-
isEqual
Test whether this object is equal to the argument. Both objects are unaffected. (native operator: binary==)- Specified by:
isEqualin interfaceConstMassProperties- Parameters:
other- the properties to compare with (notnull, unaffected)- Returns:
trueif equal,falseif unequal
-
toString
Return a string representation of the properties object, which is unaffected.- Overrides:
toStringin classJoltPhysicsObject- Returns:
- the string representation (not
null, not empty)
-