pslib
Class OrbiterParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.ParentParticle
              extended by pslib.OrbiterParticle
All Implemented Interfaces:
PSConstants

public class OrbiterParticle
extends ParentParticle

Orbiter Class

The Orbiter object extends the ParentParticle functionality by incorporating orbit simulation. Object position is calculated from the accumulated gravities of surrounding Orbiter objects.

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
OrbiterParticle(float m)
          Create a new object instance with the specified mass, default buffer size (1) and no decay
OrbiterParticle(float m, int b)
          Create a new object instance with the specified mass and buffer size, and no decay
OrbiterParticle(float m, int b, int d)
          Create a new object instance with the specified mass, buffer size and decay
 
Method Summary
 OrbiterParticle copy()
          Return a copy of this particle
 void map(OrbiterParticle p)
          Map the properties of this particle to that specified preserving references
 void setDamping(double d)
          Set the gravitational constant
 void setMaxForce(float f)
          Set the maximum force magnitude
 void setMaxVelocity(float v)
          Set the maximum velocity magnitude
 void update(DynamicParticle[] pa)
          Update the particle
 
Methods inherited from class pslib.ParentParticle
activeParticles, attach, attach, attachedParticles, clear, debug, debug, getBufferSize, isDead, map, remove, render, render, setAlpha, setBufferSize, setColour, setColour, setColour, setColour, setPosition, setVelocity, toArray, update
 
Methods inherited from class pslib.DynamicParticle
clearBehaviour, getBehaviour, getDecay, getDecayTime, getInitialDecayTime, getMass, getRenderAlpha, getRenderSize, getSnapshot, isDynamic, map, setAlphaEnvelope, setBehaviour, setBehaviour, setDecayTime, setMass, setSizeEnvelope
 
Methods inherited from class pslib.GenericParticle
getAlpha, getColour, getPosition, getSize, getVelocity, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrbiterParticle

public OrbiterParticle(float m)
Create a new object instance with the specified mass, default buffer size (1) and no decay

Parameters:
m - mass

OrbiterParticle

public OrbiterParticle(float m,
                       int b)
Create a new object instance with the specified mass and buffer size, and no decay

Parameters:
m - mass
b - buffer size

OrbiterParticle

public OrbiterParticle(float m,
                       int b,
                       int d)
Create a new object instance with the specified mass, buffer size and decay

Parameters:
m - mass
b - buffer size
d - decay (ms)
Method Detail

setDamping

public final void setDamping(double d)
Set the gravitational constant

The gravitational constant is applied in gravitational force calculations as G in F = G * (m1 * m2) / r.

Default: 0.001

Parameters:
d - force damping

setMaxVelocity

public final void setMaxVelocity(float v)
Set the maximum velocity magnitude

If the specified value is greater than zero then the particle velocity vector will be limited in magnitude to prior to application. It should be noted that limiting the particle velocity vector may result in unpredictable simulation results.

Default 0.0

Parameters:
v - maximum velocity

setMaxForce

public final void setMaxForce(float f)
Set the maximum force magnitude

If the specified value is greater than zero then the accumulated gravitational force vector will be limited in magnitude prior to application. It should be noted that limiting the maximum force magnitude may result in unpredictable simulation results.

Default 0.0

Parameters:
f - maximum force

update

public void update(DynamicParticle[] pa)
Update the particle

Orbiter velocity is calculated by accumulating the gravitational forces of each element within the orbiter array.

Parameters:
pa - orbiter array

copy

public OrbiterParticle copy()
Return a copy of this particle

The returned particle will copy all of this objects variables and will adhere to the rules defined in DynamicParticle.map().

Overrides:
copy in class ParentParticle
Returns:
a copy of this particle
See Also:
DynamicParticle

map

public final void map(OrbiterParticle p)
Map the properties of this particle to that specified preserving references

The returned object takes a copy of all orbiter particle variables. DynamicParticle variables are mapped based on the rules defined in DynamicParticle.map().

Parameters:
p - particle
See Also:
DynamicParticle