Class VerletParticle3D

java.lang.Object
toxi.geom.Vec3D
toxi.physics3d.VerletParticle3D
All Implemented Interfaces:
Comparable<ReadonlyVec3D>, ReadonlyVec3D

public class VerletParticle3D extends 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.
  • Field Details

    • bounds

      public AABB bounds
      Bounding box, by default set to null to disable
    • constraints

      public List<ParticleConstraint3D> constraints
      An optional particle constraints, called immediately after a particle is updated (and only used if particle is unlocked (default)
    • behaviors

      public List<ParticleBehavior3D> behaviors
  • Constructor Details

    • VerletParticle3D

      public VerletParticle3D(float x, float y, float z)
      Creates particle at position xyz
      Parameters:
      x -
      y -
      z -
    • VerletParticle3D

      public VerletParticle3D(float x, float y, float z, float w)
      Creates particle at position xyz with weight w
      Parameters:
      x -
      y -
      z -
      w -
    • VerletParticle3D

      public VerletParticle3D(ReadonlyVec3D v)
      Creates particle at the position of the passed in vector
      Parameters:
      v - position
    • VerletParticle3D

      public VerletParticle3D(ReadonlyVec3D v, float w)
      Creates particle with weight w at the position of the passed in vector
      Parameters:
      v - position
      w - weight
    • VerletParticle3D

      public VerletParticle3D(VerletParticle3D p)
      Creates a copy of the passed in particle
      Parameters:
      p -
  • Method Details

    • addBehavior

      public VerletParticle3D addBehavior(ParticleBehavior3D behavior)
    • addBehavior

      public VerletParticle3D addBehavior(ParticleBehavior3D behavior, float timeStep)
    • addConstraint

      public VerletParticle3D addConstraint(ParticleConstraint3D 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
    • addForce

      public VerletParticle3D addForce(Vec3D f)
    • addVelocity

      public VerletParticle3D addVelocity(Vec3D v)
    • applyBehaviors

      public void applyBehaviors()
    • applyConstraints

      public void applyConstraints()
    • clearConstraints

      public VerletParticle3D clearConstraints()
      Removes any currently applied constraints from this particle.
      Returns:
      itself
    • clearForce

      public VerletParticle3D clearForce()
    • clearVelocity

      public VerletParticle3D clearVelocity()
    • getInvWeight

      public final float getInvWeight()
      Returns:
      the inverse weight (1/weight)
    • getPreviousPosition

      public Vec3D getPreviousPosition()
      Returns the particle's position at the most recent time step.
      Returns:
      previous position
    • getVelocity

      public Vec3D getVelocity()
    • getWeight

      public final float getWeight()
      Returns:
      the weight
    • isLocked

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

      public VerletParticle3D lock()
      Locks/immobilizes particle in space
      Returns:
      itself
    • removeBehavior

      public boolean removeBehavior(ParticleBehavior3D b)
    • removeConstraint

      public boolean removeConstraint(ParticleConstraint3D 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 VerletParticle3D scaleVelocity(float scl)
    • setPreviousPosition

      public VerletParticle3D setPreviousPosition(Vec3D p)
    • setWeight

      public void setWeight(float w)
    • unlock

      public VerletParticle3D unlock()
      Unlocks particle again
      Returns:
      itself
    • update

      public void update()