Class SpringSettings

java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.SpringSettings
All Implemented Interfaces:
ConstJoltPhysicsObject, AutoCloseable, Comparable<JoltPhysicsObject>

public final class SpringSettings extends JoltPhysicsObject
Settings used to construct a spring.
  • Constructor Details

    • SpringSettings

      public SpringSettings()
      Instantiate default settings.
  • Method Details

    • getConstraint

      public Constraint getConstraint()
      Access the underlying Constraint, if any.
      Returns:
      the pre-existing instance, or null if none
    • getConstraintSettings

      public ConstraintSettings getConstraintSettings()
      Access the underlying ConstraintSettings, 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 or T = -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

      public ESpringMode 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 or T = -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), otherwise false (hard limits)
    • setDamping

      public SpringSettings 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 c in the spring equation: F = -k * x - c * v for a linear spring or T = -k * theta - c * w for an angular spring.

      Parameters:
      damping - the desired damping (default=0)
      Returns:
      the modified settings, for chaining
    • setFrequency

      public SpringSettings 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)
      Returns:
      the modified settings, for chaining
    • setMode

      public SpringSettings setMode(ESpringMode mode)
      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

      public SpringSettings 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 k in the spring equation: F = -k * x - c * v for a linear spring or T = -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