public class Particle extends java.lang.Object implements Locatable
Modifier and Type | Field and Description |
---|---|
protected float |
age
The age of the particle.
|
static float |
DEFAULT_MASS
The default mass for the no-argument constructor.
|
protected boolean |
isDead
Whether or not this particle is dead (not attached to any forces or springs).
|
protected boolean |
isFixed
Whether or not this Particle is fixed.
|
protected Vector3D |
position
The position of the particle in 3d space.
|
protected Vector3D |
velocity
The 3d velocity of the particle.
|
Constructor and Description |
---|
Particle()
Creates a particle with the default mass determined by
DEFAULT_MASS . |
Particle(float m)
Creates a particle with a given mass.
|
Modifier and Type | Method and Description |
---|---|
Particle |
addForce(Vector3D addedForce)
Updates the force on this particle by adding the given extra force.
|
float |
age()
Reports the age of this particle.
|
Particle |
clearForce()
Clears the force on this particle.
|
float |
distanceTo(Particle p)
Calculates the distance between this particle and another.
|
Vector3D |
force()
Deprecated.
Calls to this method should replaced with calls to the more standard
getForce() . |
Vector3D |
getForce()
Reports the force currently applied to this particle.
|
processing.core.PVector |
getLocation()
Reports the location of this particle.
|
boolean |
isFixed()
Reports whether or not this particle is fixed.
|
boolean |
isFree()
Reports whether or not this particle is free.
|
Particle |
makeFixed()
Fixes the particle.
|
Particle |
makeFree()
Frees this particle.
|
float |
mass()
Reports the particle's mass.
|
Vector3D |
position()
Reports the position of the particle.
|
Particle |
reset()
Resets this particle by setting its age to 0, dead=false, clears the position, velocity, force Vector3Ds, and mass = DEFAULT_MASS.
|
Particle |
setFixed(boolean isFixed)
Sets the particle's fixed/free state.
|
Particle |
setMass(float m)
Sets the particle's mass to the given value.
|
Vector3D |
velocity()
Reports the velocity of the particle.
|
public static final float DEFAULT_MASS
protected boolean isFixed
protected Vector3D position
protected Vector3D velocity
protected float age
protected boolean isDead
public Particle()
DEFAULT_MASS
.public Particle(float m) throws java.lang.IllegalArgumentException
m
- the desired mass which must be greater than 0.java.lang.IllegalArgumentException
- via setMass(float)
if mass is negative or zero.public final float distanceTo(Particle p) throws java.lang.NullPointerException
p
- the other particlejava.lang.NullPointerException
- if p == nullpublic final Particle makeFixed()
public final Particle makeFree()
public final Particle setFixed(boolean isFixed)
isFixed
- the new fixed/free state, fixed if true, free if false.public final boolean isFixed()
public final boolean isFree()
public final Vector3D position()
public processing.core.PVector getLocation()
getLocation
in interface Locatable
public final Vector3D velocity()
public final float mass()
public final Particle setMass(float m)
m
- the new mass which must be greater than 0.java.lang.IllegalArgumentException
- if its mass is set to less than 0.@Deprecated public final Vector3D force()
getForce()
.clearForce()
instead. Using this to add force is deprecated; use addForce(Vector3D)
instead.public final Vector3D getForce()
public final Particle addForce(Vector3D addedForce)
addedForce
- The force to add to the current particle forcejava.lang.NullPointerException
- via Vector3D.add(Vector3D)
if added==nullpublic final Particle clearForce()
public final float age()
public Particle reset()