Class ParticleString2D

java.lang.Object
toxi.physics2d.ParticleString2D

public class ParticleString2D extends Object
Utility builder/grouping/management class to connect a set of particles into a physical string/thread. Custom spring types can be used by subclassing this class and overwriting the createSpring(VerletParticle2D, VerletParticle2D, float, float) method.
  • Field Details

  • Constructor Details

    • ParticleString2D

      public ParticleString2D(VerletPhysics2D physics, List<VerletParticle2D> plist, float strength)
      Takes a list of already created particles connects them into a continuous string using springs.
      Parameters:
      physics - physics engine instance
      plist - particle list
      strength - spring strength
    • ParticleString2D

      public ParticleString2D(VerletPhysics2D physics, Vec2D pos, Vec2D step, int num, float mass, float strength)
      Creates a number of particles along a line and connects them into a string using springs.
      Parameters:
      physics - physics engine
      pos - start position
      step - step direction & distance between successive particles
      num - number of particles
      mass - particle mass
      strength - spring strength
  • Method Details

    • clear

      public void clear()
      Removes the entire string from the physics simulation, incl. all of its particles & springs.
    • getHead

      public VerletParticle2D getHead()
      Returns the first particle of the string.
      Returns:
      first particle
    • getNumParticles

      public int getNumParticles()
      Returns number of particles of the string.
      Returns:
      particle count
    • getTail

      public VerletParticle2D getTail()
      Returns last particle of the string.
      Returns:
      last particle