Cyclone Cyclone: cyclone::Particle Class Reference

cyclone::Particle Class Reference

>Particle More...

#include <particle.h>

Collaboration diagram for cyclone::Particle:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Integration and Simulation Functions
These functions are used to simulate the particle's motion over time. A normal application sets up one or more rigid bodies, applies permanent forces (i.e. gravity), then adds transient forces each frame, and integrates, prior to rendering.

Currently the only integration function provided is the first order Newton Euler method.

void integrate (real duration)
 Integrates the particle forward in time by the given amount.ParticleIntegrate.
Accessor Functions for the Particle's State
These functions provide access to the particle's characteristics or state.

void setMass (const real mass)
 Sets the mass of the particle.
real getMass () const
 Gets the mass of the particle.
void setInverseMass (const real inverseMass)
 Sets the inverse mass of the particle.
real getInverseMass () const
 Gets the inverse mass of the particle.
bool hasFiniteMass () const
 Returns true if the mass of the particle is not-infinite.
void setDamping (const real damping)
 Sets both the damping of the particle.
real getDamping () const
 Gets the current damping value.
void setPosition (const Vector3 &position)
 Sets the position of the particle.
void setPosition (const real x, const real y, const real z)
 Sets the position of the particle by component.
void getPosition (Vector3 *position) const
 Fills the given vector with the position of the particle.
Vector3 getPosition () const
 Gets the position of the particle.
void setVelocity (const Vector3 &velocity)
 Sets the velocity of the particle.
void setVelocity (const real x, const real y, const real z)
 Sets the velocity of the particle by component.
void getVelocity (Vector3 *velocity) const
 Fills the given vector with the velocity of the particle.
Vector3 getVelocity () const
 Gets the velocity of the particle.
void setAcceleration (const Vector3 &acceleration)
 Sets the constant acceleration of the particle.
void setAcceleration (const real x, const real y, const real z)
 Sets the constant acceleration of the particle by component.
void getAcceleration (Vector3 *acceleration) const
 Fills the given vector with the acceleration of the particle.
Vector3 getAcceleration () const
 Gets the acceleration of the particle.
Force Set-up Functions
These functions set up forces to apply to the particle.

void clearAccumulator ()
 Clears the forces applied to the particle.ParticleAccum.
void addForce (const Vector3 &force)
 Adds the given force to the particle, to be applied at the next iteration only.ParticleAddForce.

Protected Attributes

Characteristic Data and State
This data holds the state of the particle. There are two sets of data: characteristics and state.

Characteristics are properties of the particle independent of its current kinematic situation. This includes mass, moment of inertia and damping properties. Two identical particles will have the same values for their characteristics.

State includes all the characteristics and also includes the kinematic situation of the particle in the current simulation. By setting the whole state data, a particle's exact game state can be replicated. Note that state does not include any forces applied to the body. Two identical rigid bodies in the same simulation will not share the same state values.

The state values make up the smallest set of independent data for the particle. Other state data is calculated from their current values. When state data is changed the dependent values need to be updated: this can be achieved either by integrating the simulation, or by calling the calculateInternals function. This two stage process is used because recalculating internals can be a costly process: all state changes should be carried out at the same time, allowing for a single call.

See also:
calculateInternals


real inverseMass
 Holds the inverse of the mass of the particle.ParticleMass.
real damping
 Holds the amount of damping applied to linear motion.ParticleDamping.
Vector3 position
 Holds the linear position of the particle in world space.
Vector3 velocity
 Holds the linear velocity of the particle in world space.ParticleIntro.
Force Accumulators
These data members store the current force and global linear acceleration of the particle.

Vector3 forceAccum
 Holds the accumulated force to be applied at the next simulation iteration only.ParticleAccum >ParticleIntro.
Vector3 acceleration
 Holds the acceleration of the particle.ParticleIntro.

Detailed Description

>Particle

/<ParticleIntro

It has position data (no orientation data), along with velocity. It can be integrated forward through time, and have linear forces, and impulses applied to it. The particle manages its state and allows access through a set of methods. />ParticleIntro


Member Function Documentation

void cyclone::Particle::addForce const Vector3 force  ) 
 

Adds the given force to the particle, to be applied at the next iteration only.ParticleAddForce.

Parameters:
force The force to apply.

void cyclone::Particle::clearAccumulator  ) 
 

Clears the forces applied to the particle.ParticleAccum.

This will be called automatically after each integration step.

Vector3 cyclone::Particle::getAcceleration  )  const
 

Gets the acceleration of the particle.

Returns:
The acceleration of the particle. The acceleration is given in world local space.

void cyclone::Particle::getAcceleration Vector3 acceleration  )  const
 

Fills the given vector with the acceleration of the particle.

Parameters:
acceleration A pointer to a vector into which to write the acceleration. The acceleration is given in world local space.

real cyclone::Particle::getDamping  )  const
 

Gets the current damping value.

real cyclone::Particle::getInverseMass  )  const
 

Gets the inverse mass of the particle.

Returns:
The current inverse mass of the particle.

real cyclone::Particle::getMass  )  const
 

Gets the mass of the particle.

Returns:
The current mass of the particle.

Vector3 cyclone::Particle::getPosition  )  const
 

Gets the position of the particle.

Returns:
The position of the particle.

void cyclone::Particle::getPosition Vector3 position  )  const
 

Fills the given vector with the position of the particle.

Parameters:
position A pointer to a vector into which to write the position.

Vector3 cyclone::Particle::getVelocity  )  const
 

Gets the velocity of the particle.

Returns:
The velocity of the particle. The velocity is given in world local space.

void cyclone::Particle::getVelocity Vector3 velocity  )  const
 

Fills the given vector with the velocity of the particle.

Parameters:
velocity A pointer to a vector into which to write the velocity. The velocity is given in world local space.

bool cyclone::Particle::hasFiniteMass  )  const
 

Returns true if the mass of the particle is not-infinite.

void cyclone::Particle::integrate real  duration  ) 
 

Integrates the particle forward in time by the given amount.ParticleIntegrate.

This function uses a Newton-Euler integration method, which is a linear approximation to the correct integral. For this reason it may be inaccurate in some cases.

void cyclone::Particle::setAcceleration const real  x,
const real  y,
const real  z
 

Sets the constant acceleration of the particle by component.

Parameters:
x The x coordinate of the new acceleration of the rigid body.
y The y coordinate of the new acceleration of the rigid body.
z The z coordinate of the new acceleration of the rigid body.

void cyclone::Particle::setAcceleration const Vector3 acceleration  ) 
 

Sets the constant acceleration of the particle.

Parameters:
acceleration The new acceleration of the particle.

void cyclone::Particle::setDamping const real  damping  ) 
 

Sets both the damping of the particle.

void cyclone::Particle::setInverseMass const real  inverseMass  ) 
 

Sets the inverse mass of the particle.

Parameters:
inverseMass The new inverse mass of the body. This may be zero, for a body with infinite mass (i.e. unmovable).
Warning:
This invalidates internal data for the particle. Either an integration function, or the calculateInternals function should be called before trying to get any settings from the particle.

void cyclone::Particle::setMass const real  mass  ) 
 

Sets the mass of the particle.

Parameters:
mass The new mass of the body. This may not be zero. Small masses can produce unstable rigid bodies under simulation.
Warning:
This invalidates internal data for the particle. Either an integration function, or the calculateInternals function should be called before trying to get any settings from the particle.

void cyclone::Particle::setPosition const real  x,
const real  y,
const real  z
 

Sets the position of the particle by component.

Parameters:
x The x coordinate of the new position of the rigid body.
y The y coordinate of the new position of the rigid body.
z The z coordinate of the new position of the rigid body.

void cyclone::Particle::setPosition const Vector3 position  ) 
 

Sets the position of the particle.

Parameters:
position The new position of the particle.

void cyclone::Particle::setVelocity const real  x,
const real  y,
const real  z
 

Sets the velocity of the particle by component.

Parameters:
x The x coordinate of the new velocity of the rigid body.
y The y coordinate of the new velocity of the rigid body.
z The z coordinate of the new velocity of the rigid body.

void cyclone::Particle::setVelocity const Vector3 velocity  ) 
 

Sets the velocity of the particle.

Parameters:
velocity The new velocity of the particle.


Member Data Documentation

Vector3 cyclone::Particle::acceleration [protected]
 

Holds the acceleration of the particle.ParticleIntro.

This value can be used to set acceleration due to gravity (its primary use), or any other constant acceleration.

real cyclone::Particle::damping [protected]
 

Holds the amount of damping applied to linear motion.ParticleDamping.

Damping is required to remove energy added through numerical instability in the integrator.

Vector3 cyclone::Particle::forceAccum [protected]
 

Holds the accumulated force to be applied at the next simulation iteration only.ParticleAccum >ParticleIntro.

This value is zeroed at each integration step.

real cyclone::Particle::inverseMass [protected]
 

Holds the inverse of the mass of the particle.ParticleMass.

It is more useful to hold the inverse mass because integration is simpler, and because in real time simulation it is more useful to have objects with infinite mass (immovable) than zero mass (completely unstable in numerical simulation).

Vector3 cyclone::Particle::position [protected]
 

Holds the linear position of the particle in world space.

Vector3 cyclone::Particle::velocity [protected]
 

Holds the linear velocity of the particle in world space.ParticleIntro.


The documentation for this class was generated from the following file: