toxi.physics
Class VerletParticle

java.lang.Object
  extended by toxi.geom.Vec3D
      extended by toxi.physics.VerletParticle
All Implemented Interfaces:
java.lang.Comparable<toxi.geom.Vec3D>

public class VerletParticle
extends toxi.geom.Vec3D

An individual 3D particle for use by the VerletPhysics and VerletSpring classes. A particle has weight, can be locked in space and its position constrained inside an (optional) axis-aligned bounding box.

Author:
toxi

Nested Class Summary
 
Nested classes/interfaces inherited from class toxi.geom.Vec3D
toxi.geom.Vec3D.Axis
 
Field Summary
 toxi.geom.AABB bounds
          Bounding box, by default set to null to disable
 java.util.ArrayList<ParticleConstraint> constraints
          An optional particle constraints, called immediately after a particle is updated (and only used if particle is unlocked (default)
 
Fields inherited from class toxi.geom.Vec3D
MAX_VALUE, MIN_VALUE, x, X_AXIS, y, Y_AXIS, z, Z_AXIS, ZERO
 
Constructor Summary
VerletParticle(float x, float y, float z)
          Creates particle at position xyz
VerletParticle(float x, float y, float z, float w)
          Creates particle at position xyz with weight w
VerletParticle(toxi.geom.Vec3D v)
          Creates particle at the position of the passed in vector
VerletParticle(toxi.geom.Vec3D v, float w)
          Creates particle with weight w at the position of the passed in vector
VerletParticle(VerletParticle p)
          Creates a copy of the passed in particle
 
Method Summary
 VerletParticle addConstraint(ParticleConstraint c)
          Adds the given constraint implementation to the list of constraints applied to this particle at each time step.
 VerletParticle addVelocity(toxi.geom.Vec3D v)
           
 void applyConstraints()
           
 VerletParticle clearVelocity()
           
 toxi.geom.Vec3D getPreviousPosition()
          Returns the particle's position at the most recent time step.
 float getWeight()
           
 boolean isLocked()
           
 VerletParticle lock()
          Locks/immobilizes particle in space
 VerletParticle removeAllConstraints()
          Removes any currently applied constraints from this particle.
 boolean removeConstraint(ParticleConstraint c)
          Attempts to remove the given constraint instance from the list of active constraints.
 VerletParticle scaleVelocity(float scl)
           
 void setWeight(float w)
           
 VerletParticle unlock()
          Unlocks particle again
 
Methods inherited from class toxi.geom.Vec3D
abs, add, add, addSelf, addSelf, angleBetween, angleBetween, clear, closestPointOnLine, compareTo, constrain, constrain, copy, cross, crossInto, crossSelf, distanceTo, distanceToSquared, dot, equals, equalsWithTolerance, floor, frac, fromXYTheta, fromXZTheta, fromYZTheta, getAbs, getComponent, getConstrained, getFloored, getFrac, getInverted, getLimited, getNormalized, getNormalizedTo, getReciprocal, getRotatedAroundAxis, getRotatedX, getRotatedY, getRotatedZ, getSignum, hashCode, headingXY, headingXZ, headingYZ, interpolateTo, interpolateTo, interpolateToSelf, interpolateToSelf, invert, isInAABB, isInAABB, isZeroVector, jitter, jitter, jitter, limit, magnitude, magSquared, max, maxSelf, min, minSelf, modSelf, modSelf, normalize, normalizeTo, randomVector, randomVector, reciprocal, rotateAroundAxis, rotateX, rotateY, rotateZ, scale, scale, scale, scaleSelf, scaleSelf, scaleSelf, set, set, setComponent, setXY, signum, sub, sub, subSelf, subSelf, to2DXY, to2DXZ, to2DYZ, toArray, toCartesian, toSpherical, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bounds

public toxi.geom.AABB bounds
Bounding box, by default set to null to disable


constraints

public java.util.ArrayList<ParticleConstraint> constraints
An optional particle constraints, called immediately after a particle is updated (and only used if particle is unlocked (default)

Constructor Detail

VerletParticle

public VerletParticle(float x,
                      float y,
                      float z)
Creates particle at position xyz

Parameters:
x -
y -
z -

VerletParticle

public VerletParticle(float x,
                      float y,
                      float z,
                      float w)
Creates particle at position xyz with weight w

Parameters:
x -
y -
z -
w -

VerletParticle

public VerletParticle(toxi.geom.Vec3D v)
Creates particle at the position of the passed in vector

Parameters:
v - position

VerletParticle

public VerletParticle(toxi.geom.Vec3D v,
                      float w)
Creates particle with weight w at the position of the passed in vector

Parameters:
v - position
w - weight

VerletParticle

public VerletParticle(VerletParticle p)
Creates a copy of the passed in particle

Parameters:
p -
Method Detail

addConstraint

public VerletParticle addConstraint(ParticleConstraint c)
Adds the given constraint implementation to the list of constraints applied to this particle at each time step.

Parameters:
c - constraint instance
Returns:
itself

addVelocity

public VerletParticle addVelocity(toxi.geom.Vec3D v)

applyConstraints

public void applyConstraints()

clearVelocity

public VerletParticle clearVelocity()

getPreviousPosition

public toxi.geom.Vec3D getPreviousPosition()
Returns the particle's position at the most recent time step.

Returns:
previous position

getWeight

public float getWeight()
Returns:
the weight

isLocked

public boolean isLocked()
Returns:
true, if particle is locked

lock

public VerletParticle lock()
Locks/immobilizes particle in space

Returns:
itself

removeAllConstraints

public VerletParticle removeAllConstraints()
Removes any currently applied constraints from this particle.

Returns:
itself

removeConstraint

public boolean removeConstraint(ParticleConstraint c)
Attempts to remove the given constraint instance from the list of active constraints.

Parameters:
c - constraint to remove
Returns:
true, if successfully removed

scaleVelocity

public VerletParticle scaleVelocity(float scl)

setWeight

public void setWeight(float w)

unlock

public VerletParticle unlock()
Unlocks particle again

Returns:
itself