pslib
Class AttractiveForce

java.lang.Object
  extended by pslib.PSForce
      extended by pslib.AttractiveForce
All Implemented Interfaces:
PSBehaviour, PSConstants

public class AttractiveForce
extends PSForce

AttractorForce Class

The AttractorForce object extends the PSForce class allowing an attractive force to be applied to a DynamicParticle object.

If no radius is specified the force magnitude increases, the further a particle gets from the force position. If a radius is specified, then force magnitude is calculated based on the position of the particle within the force radius, with the centre creating the largest magnitude.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.


Field Summary
 
Fields inherited from interface pslib.PSConstants
CAM2D_LOOK, CAM2D_RIGHT, CAM2D_UP, CORNER, INVERSE, INVERSE_TRIANGULAR, LEADING, LINEAR, MIDPOINT, NONE, STATIC, TRAILING, TRIANGULAR
 
Constructor Summary
AttractiveForce(PSVector p, float m)
          Create a static object instance with the specified values
AttractiveForce(PSVector p, float r, float m)
          Create a static object instance with the specified values
AttractiveForce(PSVector p, float r, float mi, float ma, int m, float c)
          Create a dynamic object instance with the specified values
AttractiveForce(PSVector p, float mi, float ma, int m, float c)
          Create a dynamic object instance with the specified values
 
Method Summary
 PSVector getPosition()
          Return the force position
 void setDamping(float d)
          Set force damping for non-radial behaviour
 void setDistanceCurve(float c)
          Set the distance curve exponent
 void setPosition(PSVector p)
          Set the force position
 void update(DynamicParticle p)
          Update the specified particle
 
Methods inherited from class pslib.PSForce
getDimensionScalars, getMagnitude, getScale, setCurve, setDimensionScalars, setScale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttractiveForce

public AttractiveForce(PSVector p,
                       float m)
Create a static object instance with the specified values

Parameters:
p - position
m - magnitude

AttractiveForce

public AttractiveForce(PSVector p,
                       float r,
                       float m)
Create a static object instance with the specified values

Parameters:
p - position
r - radius
m - magnitude

AttractiveForce

public AttractiveForce(PSVector p,
                       float r,
                       float mi,
                       float ma,
                       int m,
                       float c)
Create a dynamic object instance with the specified values

Parameters:
p - position
r - radius
mi - minimum magnitude
ma - maximum magnitude
m - mode
c - decay curve exponent

AttractiveForce

public AttractiveForce(PSVector p,
                       float mi,
                       float ma,
                       int m,
                       float c)
Create a dynamic object instance with the specified values

Parameters:
p - position
mi - minimum magnitude
ma - maximum magnitude
m - mode
c - decay curve exponent
Method Detail

setPosition

public void setPosition(PSVector p)
Set the force position

Parameters:
p - position

getPosition

public PSVector getPosition()
Return the force position

Returns:
the force position

setDamping

public void setDamping(float d)
Set force damping for non-radial behaviour

Default: 0.01

Parameters:
d - damping

setDistanceCurve

public void setDistanceCurve(float c)
Set the distance curve exponent

Parameters:
c - curve exponent

update

public void update(DynamicParticle p)
Update the specified particle

Specified by:
update in interface PSBehaviour
Specified by:
update in class PSForce
Parameters:
p - particle