#include <rimPhysicsObjectParticle.h>
Public Member Functions | |
Particle () | |
Create a stationary particle at the origin with no mass and zero radius. | |
Particle (const Vector3 &newPosition) | |
Create a stationary particle at a position with no mass and zero radius. | |
Particle (const Vector3 &newPosition, Real newMass, Real newRadius) | |
Create a stationary particle at a position with a mass and radius. | |
Particle (const Vector3 &newPosition, const Vector3 &newVelocity, Real newMass, Real newRadius) | |
Create a moving particle at a position with a mass and radius. | |
const Vector3 & | getPosition () const |
Get a constant reference to this particle's position in 3D space. | |
void | setPosition (const Vector3 &newPosition) |
Set this particle's position in 3D space. | |
const Vector3 & | getVelocity () const |
void | setVelocity (const Vector3 &newVelocity) |
void | setVelocity (Real newVelX, Real newVelY, Real newVelZ) |
void | applyImpulse (const Vector3 &j) |
Apply an impulse to the particle's center of mass. | |
const Vector3 & | getForce () const |
void | setForce (const Vector3 &newForce) |
void | setForce (Real newForceX, Real newForceY, Real newForceZ) |
void | applyForce (const Vector3 &f) |
Apply a force directly to the center of mass of the object. | |
Real | getMass () const |
void | setMass (Real newMass) |
Real | getInverseMass () const |
Real | getDensity () const |
Real | getRadius () const |
void | setRadius (Real newRadius) |
Real | getVolume () const |
Real | getFriction () const |
void | setFriction (Real newFriction) |
Real | getElasticity () const |
void | setElasticity (Real newElasticity) |
Private Attributes | |
Vector3 | position |
the current position vector of the particle in 3D world space. | |
Vector3 | velocity |
the current velocity vector of the particle in 3D world space. | |
Vector3 | force |
the current force vector of the particle in 3D world space. | |
Real | mass |
The mass of the particle. | |
Real | inverseMass |
The pre-calculated inverse mass of the particle, equal to 0 if the mass is 0. | |
Real | friction |
A single value for both kinetic and static friction coefficients. | |
Real | elasticity |
The coefficient of restitution for the particle. | |
Real | radius |
The radius of the spherical particle. | |
Real | volume |
The volume of the particle. |
The purpose of the Particle class is to provide a type of object which is suitable for large systems of many objects which do not require fine simulation detail. It is ideal for simulating traditional particle effects such as water and fire. Each particle has the following properties: 3D position, velocity, and net force vectors, radius, mass, volume, friction, elasticity and density. Some of these properties depend on the others. For example, volume is calculated from the radius of the particle, as every particle is spherical, and density is calculated from the volume and mass of the particle. Particles are non-rotational which greatly increases the efficiency of simulation, but this makes them unsuitable for objects which require rotation. Use a rigid body for those objects.
Particle::Particle | ( | ) | [inline] |
Create a stationary particle at the origin with no mass and zero radius.
Particle::Particle | ( | const Vector3 & | newPosition | ) | [inline] |
Create a stationary particle at a position with no mass and zero radius.
Create a stationary particle at a position with a mass and radius.
Particle::Particle | ( | const Vector3 & | newPosition, | |
const Vector3 & | newVelocity, | |||
Real | newMass, | |||
Real | newRadius | |||
) | [inline] |
Create a moving particle at a position with a mass and radius.
const Vector3& Particle::getPosition | ( | ) | const [inline] |
Get a constant reference to this particle's position in 3D space.
void Particle::setPosition | ( | const Vector3 & | newPosition | ) | [inline] |
Set this particle's position in 3D space.
const Vector3& Particle::getVelocity | ( | ) | const [inline] |
void Particle::setVelocity | ( | const Vector3 & | newVelocity | ) | [inline] |
void Particle::applyImpulse | ( | const Vector3 & | j | ) | [inline] |
Apply an impulse to the particle's center of mass.
const Vector3& Particle::getForce | ( | ) | const [inline] |
void Particle::setForce | ( | const Vector3 & | newForce | ) | [inline] |
void Particle::applyForce | ( | const Vector3 & | f | ) | [inline] |
Apply a force directly to the center of mass of the object.
Real Particle::getMass | ( | ) | const [inline] |
void Particle::setMass | ( | Real | newMass | ) | [inline] |
Real Particle::getInverseMass | ( | ) | const [inline] |
Real Particle::getDensity | ( | ) | const [inline] |
Real Particle::getRadius | ( | ) | const [inline] |
void Particle::setRadius | ( | Real | newRadius | ) | [inline] |
Real Particle::getVolume | ( | ) | const [inline] |
Real Particle::getFriction | ( | ) | const [inline] |
void Particle::setFriction | ( | Real | newFriction | ) | [inline] |
Real Particle::getElasticity | ( | ) | const [inline] |
void Particle::setElasticity | ( | Real | newElasticity | ) | [inline] |
Vector3 Particle::position [private] |
the current position vector of the particle in 3D world space.
Vector3 Particle::velocity [private] |
the current velocity vector of the particle in 3D world space.
Vector3 Particle::force [private] |
the current force vector of the particle in 3D world space.
Real Particle::mass [private] |
The mass of the particle.
Real Particle::inverseMass [private] |
The pre-calculated inverse mass of the particle, equal to 0 if the mass is 0.
Real Particle::friction [private] |
A single value for both kinetic and static friction coefficients.
Since a particle is such a simple object and is non-rotational, there is only one value for both of its coefficient of friction. This value affects how much translational motion across a surface by the particle is dampened. A value of 0 means that the particle is frictionless, and any higher value increases the amount of friction of the particle. Any negative values are clamped at 0. The default coefficient of friction for a particle is 0.
Real Particle::elasticity [private] |
The coefficient of restitution for the particle.
This value determines how much a particle will rebound whenever it hits another object. A value of 0 means that the particle will collide completely inelastically, such that all kinetic energy is lost in the collision, while a value of 1 means that the particle will collide in a perfectly elastic manner, loosing no kinetic energy. Any value over 1 means that kinetic energy will be generated in the collision (i.e. Flubber). This is not recommended, as it will cause the simulation to become unstable. Any negative values will be clamped at 0. The default elasticity for a particle is 0.
Real Particle::radius [private] |
The radius of the spherical particle.
This value is directly setable by the user through the setRadius() method. Any change to the radius of the particle also indirectly affects both its volume and density. The default radius of a particle is zero.
Real Particle::volume [private] |
The volume of the particle.
The user cannot directly change the volume of a particle, because this value is linked to its radius. Whenever the radius is changed, the volume is updated to reflect this new value. The default volume for a particle is zero, like the default radius.