Class SpringSettings
- All Implemented Interfaces:
ConstJoltPhysicsObject,AutoCloseable,Comparable<ConstJoltPhysicsObject>
-
Method Summary
Modifier and TypeMethodDescriptionAccess the underlyingConstraint, if any.Access the underlyingConstraintSettings, if any.floatReturn the spring's damping.floatReturn the spring's frequency.getMode()Return how the spring is specified.floatReturn the spring's stiffness.booleanTest for valid frequency/stiffness.voidsetDamping(float damping) Alter the spring's damping.voidsetFrequency(float frequency) Alter the spring's frequency.voidsetMode(ESpringMode mode) Alter how the spring is specified.voidsetStiffness(float stiffness) Alter the stiffness of the spring.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, startCleaner, toString, va
-
Method Details
-
getConstraint
Access the underlyingConstraint, if any.- Returns:
- the pre-existing instance, or null if none
-
getConstraintSettings
Access the underlyingConstraintSettings, if any.- Returns:
- the pre-existing instance, or null if none
-
getDamping
public float getDamping()Return the spring's damping. The settings are unaffected. (native attribute: mDamping)When the mode is FrequencyAndDamping, this is the damping ratio (0 = no damping, 1 = critical damping). When the mode is StiffnessAndDamping, this is the damping coefficient
cin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.- Returns:
- the damping value
-
getFrequency
public float getFrequency()Return the spring's frequency. The settings are unaffected. (native attribute: mFrequency)Effective only when the mode is FrequencyAndDamping. If positive, the constraint will have soft limits, and mFrequency specifies the oscillation frequency in Hz. If negative, the constraint will have hard limits.
- Returns:
- the frequency value
-
getMode
Return how the spring is specified. The settings are unaffected. (native attribute: mMode)- Returns:
- an enum value (not null)
-
getStiffness
public float getStiffness()Return the spring's stiffness. The settings are unaffected. (native attribute: mStiffness)Effective only when the mode is StiffnessAndDamping. If positive, the constraint will have soft limits, and mStiffness specifies the stiffness
kin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.If negative, the constraint will have hard limits.
- Returns:
- the stiffness value
-
hasStiffness
public boolean hasStiffness()Test for valid frequency/stiffness. The settings are unaffected.- Returns:
- true if valid (the constraint will have soft limits), otherwise false (hard limits)
-
setDamping
public void setDamping(float damping) Alter the spring's damping. (native attribute: mDamping)When the mode is FrequencyAndDamping, this is the damping ratio (0 = no damping, 1 = critical damping). When the mode is StiffnessAndDamping, this is the damping coefficient
cin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.- Parameters:
damping- the desired damping (default=0)
-
setFrequency
public void setFrequency(float frequency) Alter the spring's frequency. (native attribute: mFrequency)Effective only when the mode is FrequencyAndDamping. If positive, the constraint will have soft limits, and mFrequency specifies the oscillation frequency in Hz. Otherwise the constraint will have hard limits.
- Parameters:
frequency- the desired frequency (default=0)
-
setMode
Alter how the spring is specified. (native attribute: mMode)- Parameters:
mode- the desired mode (not null, default=FrequencyAndDamping)
-
setStiffness
public void setStiffness(float stiffness) Alter the stiffness of the spring. (native attribute: mStiffness)Effective only when the mode is StiffnessAndDamping. If positive, the constraint will have soft limits, and mStiffness specifies the stiffness
kin the spring equation:F = -k * x - c * vfor a linear spring orT = -k * theta - c * wfor an angular spring.If negative, the constraint will have hard limits.
- Parameters:
stiffness- (default=0)
-