- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAccess the underlyingConstraint
, if any.Access the underlyingConstraintSettings
, if any.float
Return the spring's damping.float
Return the spring's frequency.getMode()
Return how the spring is specified.float
Return the spring's stiffness.boolean
Test for valid frequency/stiffness.setDamping
(float damping) Alter the spring's damping.setFrequency
(float frequency) Alter the spring's frequency.setMode
(ESpringMode mode) Alter how the spring is specified.setStiffness
(float stiffness) Alter the stiffness of the spring.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
SpringSettings
public SpringSettings()Instantiate default settings.
-
-
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
c
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for 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
k
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for 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), otherwisefalse
(hard limits)
-
setDamping
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
c
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for an angular spring.- Parameters:
damping
- the desired damping (default=0)- Returns:
- the modified settings, for chaining
-
setFrequency
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)- Returns:
- the modified settings, for chaining
-
setMode
Alter how the spring is specified. (native attribute: mMode)- Parameters:
mode
- the desired mode (not null, default=FrequencyAndDamping)- Returns:
- the modified settings, for chaining
-
setStiffness
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
k
in the spring equation:F = -k * x - c * v
for a linear spring orT = -k * theta - c * w
for an angular spring.If negative, the constraint will have hard limits.
- Parameters:
stiffness
- (default=0)- Returns:
- the modified settings, for chaining
-