Class AttractionBehavior2D

java.lang.Object
toxi.physics2d.behaviors.AttractionBehavior2D
All Implemented Interfaces:
ParticleBehavior2D

public class AttractionBehavior2D extends Object implements ParticleBehavior2D
  • Constructor Details

    • AttractionBehavior2D

      public AttractionBehavior2D(Vec2D attractor, float radius, float strength)
    • AttractionBehavior2D

      public AttractionBehavior2D(Vec2D attractor, float radius, float strength, float jitter)
  • Method Details

    • apply

      public void apply(VerletParticle2D p)
      Description copied from interface: ParticleBehavior2D
      Applies the constraint to the passed in particle. The method is assumed to manipulate the given instance directly.
      Specified by:
      apply in interface ParticleBehavior2D
      Parameters:
      p - particle
    • applyWithIndex

      public void applyWithIndex(SpatialIndex<Vec2D> spaceHash)
      Specified by:
      applyWithIndex in interface ParticleBehavior2D
    • configure

      public void configure(float timeStep)
      Specified by:
      configure in interface ParticleBehavior2D
    • getAttractor

      public Vec2D getAttractor()
      Returns:
      the attractor
    • getJitter

      public float getJitter()
      Returns:
      the jitter
    • getRadius

      public float getRadius()
      Returns:
      the radius
    • getStrength

      public float getStrength()
      Returns:
      the strength
    • setAttractor

      public void setAttractor(Vec2D attractor)
      Parameters:
      attractor - the attractor to set
    • setJitter

      public void setJitter(float jitter)
      Parameters:
      jitter - the jitter to set
    • setRadius

      public void setRadius(float r)
    • setStrength

      public void setStrength(float strength)
      Parameters:
      strength - the strength to set
    • supportsSpatialIndex

      public boolean supportsSpatialIndex()
      Specified by:
      supportsSpatialIndex in interface ParticleBehavior2D