Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## toxi.physics
Class VerletPhysics

    java.lang.Object
      toxi.physics.VerletPhysics

    public class VerletPhysics

extends java.lang.Object

3D particle physics engine using Verlet integration based on: http://en.wikipedia.org/wiki/Verlet_integration http://www.teknikus.dk/tj/gdc2001.htm

Field Summary
`java.util.List<ParticleBehavior>` | `behaviors`
`java.util.List<VerletParticle>` | `particles` List of particles (Vec3D subclassed)
`java.util.List<VerletSpring>` | `springs` List of spring/sticks connectors

Constructor Summary
`VerletPhysics()` Initializes a Verlet engine instance using the default values.
`VerletPhysics(toxi.geom.Vec3D gravity, int numIterations, float drag, float timeStep)` Initializes an Verlet engine instance with the passed in configuration.

Method Summary
`void` | `addBehavior(ParticleBehavior behavior)`
`static void` | `addConstraintToAll(ParticleConstraint c, java.util.List<VerletParticle> list)`
`VerletPhysics` | `addParticle(VerletParticle p)` Adds a particle to the list
`VerletPhysics` | `addSpring(VerletSpring s)` Adds a spring connector
`VerletPhysics` | `clear()`
`toxi.geom.AABB` | `getCurrentBounds()`
`float` | `getDrag()`
`int` | `getNumIterations()`
`VerletSpring` | `getSpring(toxi.geom.Vec3D a, toxi.geom.Vec3D b)` Attempts to find the spring element between the 2 particles supplied
`float` | `getTimeStep()`
`toxi.geom.AABB` | `getWorldBounds()`
`boolean` | `removeBehavior(ParticleBehavior b)`
`static void` | `removeConstraintFromAll(ParticleConstraint c, java.util.List<VerletParticle> list)`
`boolean` | `removeParticle(VerletParticle p)` Removes a particle from the simulation.
`boolean` | `removeSpring(VerletSpring s)` Removes a spring connector from the simulation instance.
`boolean` | `removeSpringElements(VerletSpring s)` Removes a spring connector and its both end point particles from the simulation
`void` | `setDrag(float drag)`
`void` | `setNumIterations(int numIterations)`
`void` | `setTimeStep(float timeStep)`
`VerletPhysics` | `setWorldBounds(toxi.geom.AABB world)` Sets bounding box
`VerletPhysics` | `update()` Progresses the physics simulation by 1 time step and updates all forces and particle positions accordingly

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### particles

    public java.util.List<VerletParticle> particles

  List of particles (Vec3D subclassed)

### springs

    public java.util.List<VerletSpring> springs

  List of spring/sticks connectors

### behaviors

    public final java.util.List<ParticleBehavior> behaviors

Constructor Detail

### VerletPhysics

    public VerletPhysics()

  Initializes a Verlet engine instance using the default values.

### VerletPhysics

    public VerletPhysics(toxi.geom.Vec3D gravity,
                         int numIterations,
                         float drag,
                         float timeStep)

  Initializes an Verlet engine instance with the passed in configuration.

  Parameters:
    `gravity` - 3D gravity vector
    `numIterations` - iterations per time step for verlet solver
    `drag` - drag value 0...1
    `timeStep` - time step for calculating forces

Method Detail

### addConstraintToAll

    public static void addConstraintToAll(ParticleConstraint c,
                                          java.util.List<VerletParticle> list)

### removeConstraintFromAll

    public static void removeConstraintFromAll(ParticleConstraint c,
                                               java.util.List<VerletParticle> list)

### addBehavior

    public void addBehavior(ParticleBehavior behavior)

### addParticle

    public VerletPhysics addParticle(VerletParticle p)

  Adds a particle to the list

  Parameters:
    `p` -
  Returns:
    itself

### addSpring

    public VerletPhysics addSpring(VerletSpring s)

  Adds a spring connector

  Parameters:
    `s` -
  Returns:
    itself

### clear

    public VerletPhysics clear()

### getCurrentBounds

    public toxi.geom.AABB getCurrentBounds()

### getDrag

    public float getDrag()

### getNumIterations

    public int getNumIterations()

  Returns:
    the numIterations

### getSpring

    public VerletSpring getSpring(toxi.geom.Vec3D a,
                                  toxi.geom.Vec3D b)

  Attempts to find the spring element between the 2 particles supplied

  Parameters:
    `a` - particle 1
    `b` - particle 2
  Returns:
    spring instance, or null if not found

### getTimeStep

    public float getTimeStep()

  Returns:
    the timeStep

### getWorldBounds

    public toxi.geom.AABB getWorldBounds()

  Returns:
    the worldBounds

### removeBehavior

    public boolean removeBehavior(ParticleBehavior b)

### removeParticle

    public boolean removeParticle(VerletParticle p)

  Removes a particle from the simulation.

  Parameters:
    `p` - particle to remove
  Returns:
    true, if removed successfully

### removeSpring

    public boolean removeSpring(VerletSpring s)

  Removes a spring connector from the simulation instance.

  Parameters:
    `s` - spring to remove
  Returns:
    true, if the spring has been removed

### removeSpringElements

    public boolean removeSpringElements(VerletSpring s)

  Removes a spring connector and its both end point particles from the simulation

  Parameters:
    `s` - spring to remove
  Returns:
    true, only if spring AND particles have been removed successfully

### setDrag

    public void setDrag(float drag)

### setNumIterations

    public void setNumIterations(int numIterations)

  Parameters:
    `numIterations` - the numIterations to set

### setTimeStep

    public void setTimeStep(float timeStep)

  Parameters:
    `timeStep` - the timeStep to set

### setWorldBounds

    public VerletPhysics setWorldBounds(toxi.geom.AABB world)

  Sets bounding box

  Parameters:
    `world` -
  Returns:
    itself

### update

    public VerletPhysics update()

  Progresses the physics simulation by 1 time step and updates all forces and particle positions accordingly

  Returns:
    itself

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD