Class VerletSpring2D

java.lang.Object
toxi.physics2d.VerletSpring2D
Direct Known Subclasses:
VerletConstrainedSpring2D, VerletMinDistanceSpring2D

public class VerletSpring2D extends Object

A spring class connecting two VerletParticles in space. Based on the configuration of the spring instance and that of the physics engine, the behaviour of the spring can vary between springy and stiff/stick like.

The simulation takes particle weights into account and can be configured to lock either particle in space in order to force the other one to move. This is sometimes handy for resolving collisions (currently outside the scope of this library).

See Also:
  • Field Details

  • Constructor Details

    • VerletSpring2D

      public VerletSpring2D(VerletParticle2D a, VerletParticle2D b, float len, float str)
      Parameters:
      a - 1st particle
      b - 2nd particle
      len - desired rest length
      str - spring strength
  • Method Details

    • getRestLength

      public float getRestLength()
    • getStrength

      public float getStrength()
    • lockA

      public VerletSpring2D lockA(boolean s)
      (Un)Locks the 1st end point of the spring. NOTE: this acts purely within the scope of this spring instance and does NOT call VerletParticle2D.lock()
      Parameters:
      s -
      Returns:
      itself
    • lockB

      public VerletSpring2D lockB(boolean s)
      (Un)Locks the 2nd end point of the spring
      Parameters:
      s -
      Returns:
      itself
    • setRestLength

      public VerletSpring2D setRestLength(float len)
    • setStrength

      public VerletSpring2D setStrength(float strength)