|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gicentre.utils.network.traer.physics.ParticleSystem
public class ParticleSystem
Represents an entire particle system containing particles and forces between them.
Field Summary | |
---|---|
protected static float |
DEFAULT_DRAG
Default drag on all particles. |
protected static float |
DEFAULT_GRAVITY
The default magnitude for the y-component of gravity. |
static int |
MODIFIED_EULER
Deprecated. Use the enum values defined in the Integrator class in preference to this. |
static int |
RUNGE_KUTTA
Deprecated. Use the enum values defined in the Integrator class in preference to this. |
Constructor Summary | |
---|---|
ParticleSystem()
Creates a particle system with no gravity and default drag on particles. |
|
ParticleSystem(float g,
float drag)
Creates a particle system with the given gravitational pull and drag. |
|
ParticleSystem(float gx,
float gy,
float gz,
float drag)
Creates a particle system with the given 3d gravitational pull and drag. |
Method Summary | |
---|---|
ParticleSystem |
addCustomForce(AbstractForce customForce)
Adds a custom force to those in this particle system. |
protected void |
applyForces()
Applies the forces contained in this particle system to those particles subject to them. |
java.util.Collection<Attraction> |
attractions()
Deprecated. Replace in favour of the more consistently named getAttractions(). |
void |
clear()
Clears the particle system of all particles, springs, attractions and custom forces. |
void |
clearAllForces()
Removes all forces, springs and attractions from the particle system. |
protected void |
clearForces()
Removes all forces from this particle system. |
java.util.Collection<AbstractForce> |
customForces()
Deprecated. Replace in favour of the more consistently named getCustomForces(). |
Attraction |
getAttraction(int i)
Provides the attraction at the given position in the collection of attractions stored in this particle system. |
java.util.Collection<Attraction> |
getAttractions()
Reports a collection of the attractions currently defined as part of this particle system. |
AbstractForce |
getCustomForce(int i)
Provides the custom force at the given position in the collection of custom forces stored in this particle system. |
java.util.Collection<AbstractForce> |
getCustomForces()
Provides a collection of the custom forces currently defined as part of this particle system. |
float |
getDeltaT()
Reports the current time step size used by this ParticleSystem's Integrator. |
int |
getNumAttractions()
Reports the number of attractions in this particle system. |
int |
getNumCustomForces()
Reports the number of custom forces in this particle system. |
int |
getNumParticles()
Reports the number of particles in this particle system. |
int |
getNumSprings()
Reports the number of springs in this particle system. |
Particle |
getParticle(int i)
Provides the particle at the given position in the collection of particles stored in this particle system. |
java.util.Collection<Particle> |
getParticles()
Provides a collection of the particles currently defined as part of this particle system. |
Spring |
getSpring(int i)
Provides the spring at the given position in the collection of springs stored in this particle system. |
java.util.Collection<Spring> |
getSprings()
Reports a collection of the springs currently defined as part of this particle system. |
Attraction |
makeAttraction(Particle a,
Particle b,
float strength,
float minDistance)
Creates an attractive force between the given particles with the given strength. |
Particle |
makeParticle()
Creates a Particle with Particle.DEFAULT_MASS and position=(0,0,0). |
Particle |
makeParticle(float mass,
float x,
float y,
float z)
Creates a particle in the ParticleSystem, and returns that Particle |
Particle |
makeParticle(Particle p)
Adds a custom Particle to the ParticleSystem, and returns the ParticleSystem. |
Spring |
makeSpring(Particle a,
Particle b,
float strength,
float damping,
float restLength)
Creates a spring between the given particles with the given strength, damping and reset length. |
int |
numberOfAttractions()
Deprecated. Replace in favour of the more consistently named getNumAttractions(). |
int |
numberOfCustomForces()
Deprecated. Replace in favour of the more consistently named getNumCustomForces(). |
int |
numberOfParticles()
Deprecated. Replace in favour of the more consistently named getParticles(). |
int |
numberOfSprings()
Deprecated. Replace in favour of the more consistently named getNumSprings(). |
java.util.Collection<Particle> |
particles()
Deprecated. Replace in favour of the more consistently named getParticles(). |
ParticleSystem |
removeAttraction(Attraction attraction)
Removes the given attraction from the collection of attractions stored in this particle system if it exists. |
Attraction |
removeAttraction(int i)
Removes the attraction at the given position in the collection of attractions stored in this particle system. |
ParticleSystem |
removeCustomForce(AbstractForce customForce)
Removes the given custom force from the collection of custom forces stored in this particle system if it exists. |
AbstractForce |
removeCustomForce(int i)
Removes the custom force at the given position in the collection of custom forces stored in this particle system. |
ParticleSystem |
removeParticle(Particle p)
Removes the given particle from the collection of particles stored in this particle system if it exists. |
Spring |
removeSpring(int i)
Removes the spring at the given position in the collection of springs stored in this particle system. |
ParticleSystem |
removeSpring(Spring spring)
Removes the given spring from the collection of springs stored in this particle system if it exists. |
ParticleSystem |
setDeltaT(float t)
Sets the size of the time step used with Integrator.step(float) for this ParticleSystem. |
ParticleSystem |
setDrag(float d)
Sets the drag component that affects the particles in this system. |
ParticleSystem |
setGravity(float g)
Sets the gravity with 0,g,0 components. |
ParticleSystem |
setGravity(float x,
float y,
float z)
Sets the x, y, z components of the gravity vector. |
ParticleSystem |
setIntegrator(int integrator)
Deprecated. Consider replacing with setIntegrator(Integrator.METHOD) . |
ParticleSystem |
setIntegrator(Integrator.METHOD integrator)
Sets the integrator for this particle system based on the specified integrator name. |
ParticleSystem |
setIntegrator(Integrator integrator)
Sets the integrator for this particle system based on the specified integrator. |
java.util.Collection<Spring> |
springs()
Deprecated. Replace in favour of the more consistently named getSprings(). |
ParticleSystem |
tick()
Advances this ParticleSystem's Integrator by the local time step. |
ParticleSystem |
tick(float t)
Advances this ParticleSystem's Integrator by a user-specified time step. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RUNGE_KUTTA
Integrator
class in preference to this.
public static final int MODIFIED_EULER
Integrator
class in preference to this.
protected static final float DEFAULT_DRAG
protected static final float DEFAULT_GRAVITY
Constructor Detail |
---|
public ParticleSystem()
setIntegrator()
.
public ParticleSystem(float g, float drag)
setIntegrator()
.
g
- Gravitational parameter, applied in the 'y' direction only.drag
- The drag associated with particles in this system.public ParticleSystem(float gx, float gy, float gz, float drag)
setIntegrator()
.
gx
- Gravitational parameter, applied in the 'x' direction.gy
- Gravitational parameter, applied in the 'y' direction.gz
- Gravitational parameter, applied in the 'z' direction.drag
- The drag associated with particles in this system.Method Detail |
---|
public final ParticleSystem setDeltaT(float t) throws java.lang.IllegalArgumentException
Integrator.step(float)
for this ParticleSystem.
t
- the time step size
java.lang.IllegalArgumentException
- if t<=0public final float getDeltaT()
public final ParticleSystem tick()
tick(float)
.
public final ParticleSystem tick(float t)
t
- the amount of time to advance
java.lang.IllegalArgumentException
- if t<=0@Deprecated public final ParticleSystem setIntegrator(int integrator) throws java.lang.IllegalArgumentException
setIntegrator(Integrator.METHOD)
.
integrator
- the ID corresponding to the desired Integrator
java.lang.IllegalArgumentException
- if the argument does not correspond to defined Integratorpublic final ParticleSystem setIntegrator(Integrator.METHOD integrator)
integrator
- Name of integrator to be used by this particle system.
public final ParticleSystem setIntegrator(Integrator integrator) throws java.lang.NullPointerException
integrator
- the desired integrator.
java.lang.NullPointerException
- if integrator==nullpublic final ParticleSystem setGravity(float x, float y, float z)
x
- the x component of the gravity vector.y
- the y component of the gravity vector.z
- the z component of the gravity vector.
public final ParticleSystem setGravity(float g)
g
- the y component of the gravity vector.
public final ParticleSystem setDrag(float d)
d
- the drag factor. A positive value corresponds to physical drag.
public final Particle makeParticle(float mass, float x, float y, float z)
mass
- the new Particle massx
- the x positiony
- the y positionz
- the z position
public final Particle makeParticle()
Particle.DEFAULT_MASS
and position=(0,0,0).
public final Particle makeParticle(Particle p)
p
- the custom particle
java.lang.NullPointerException
- if p==nullpublic final Spring makeSpring(Particle a, Particle b, float strength, float damping, float restLength) throws java.lang.NullPointerException
a
- First particle to be joined with the spring.b
- Second particle to be joined with the spring.strength
- Strength of the spring.damping
- The damping component of the spring.restLength
- Rest length of the spring.
java.lang.NullPointerException
- if either of the particles are null.public final Attraction makeAttraction(Particle a, Particle b, float strength, float minDistance) throws java.lang.NullPointerException
a
- First particle to be associated with the attraction.b
- Second particle to be associated with the attraction.strength
- Strength of the attraction, positive to bring particles together, negative to repulse.minDistance
- Minimum distance below which the attraction is not applied.
java.lang.NullPointerException
- if either of the particles is null.public final java.util.Collection<Spring> springs()
public final java.util.Collection<Spring> getSprings()
public final int numberOfSprings()
public final int getNumSprings()
public final Spring getSpring(int i)
i
- List index (the ith spring in the collection). While the springs are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final Spring removeSpring(int i)
i
- List index (the ith spring in the collection). While the springs are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final ParticleSystem removeSpring(Spring spring)
spring
- The spring to remove.
public final java.util.Collection<Attraction> attractions()
public final java.util.Collection<Attraction> getAttractions()
public final int numberOfAttractions()
public final int getNumAttractions()
public final Attraction getAttraction(int i)
i
- List index (the ith attraction in the collection). While the attractions are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final Attraction removeAttraction(int i)
i
- List index (the ith attraction in the collection). While the attractions are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final ParticleSystem removeAttraction(Attraction attraction)
attraction
- The attraction to remove.
public final java.util.Collection<AbstractForce> customForces()
public final java.util.Collection<AbstractForce> getCustomForces()
public final ParticleSystem addCustomForce(AbstractForce customForce)
customForce
- Custom force to add.
public final int numberOfCustomForces()
public final int getNumCustomForces()
public final AbstractForce getCustomForce(int i)
i
- List index (the ith attraction in the collection). While the custom forces are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final AbstractForce removeCustomForce(int i)
i
- List index (the ith attraction in the collection). While the custom forces are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final ParticleSystem removeCustomForce(AbstractForce customForce)
customForce
- The custom force to remove.
public final java.util.Collection<Particle> particles()
public final java.util.Collection<Particle> getParticles()
public final int numberOfParticles()
public final int getNumParticles()
public final Particle getParticle(int i)
i
- List index (the ith attraction in the collection). While the particles are stored in a fixed
insert-order, this is a non-repeating set, and future reliance on set order is not encouraged.
public final ParticleSystem removeParticle(Particle p)
p
- The particle to remove.
public final void clear()
protected final void applyForces()
protected final void clearForces()
clearAllForces()
, this
will maintain the internal collections of springs, attractions and custom forces, but these
remain unattached to any particular particles.
public final void clearAllForces()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |