toxi.physics
Class VerletSpring

java.lang.Object
  extended by toxi.physics.VerletSpring
Direct Known Subclasses:
VerletConstrainedSpring, VerletMinDistanceSpring

public class VerletSpring
extends java.lang.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).

Author:
toxi
See Also:
VerletPhysics

Field Summary
 VerletParticle a
          Spring end points / particles
 VerletParticle b
          Spring end points / particles
 float restLength
          Spring rest length to which it always wants to return too
 float strength
          Spring strength, possible value range depends on engine configuration (time step, drag)
 
Constructor Summary
VerletSpring(VerletParticle a, VerletParticle b, float len, float str)
           
 
Method Summary
 VerletSpring lockA(boolean s)
          (Un)Locks the 1st end point of the spring.
 VerletSpring lockB(boolean s)
          (Un)Locks the 2nd end point of the spring
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

public VerletParticle a
Spring end points / particles


b

public VerletParticle b
Spring end points / particles


restLength

public float restLength
Spring rest length to which it always wants to return too


strength

public float strength
Spring strength, possible value range depends on engine configuration (time step, drag)

Constructor Detail

VerletSpring

public VerletSpring(VerletParticle a,
                    VerletParticle b,
                    float len,
                    float str)
Parameters:
a - 1st particle
b - 2nd particle
len - desired rest length
str - spring strength
Method Detail

lockA

public VerletSpring 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 VerletParticle.lock()

Parameters:
s -
Returns:
itself

lockB

public VerletSpring lockB(boolean s)
(Un)Locks the 2nd end point of the spring

Parameters:
s -
Returns:
itself