Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
|
base particle class to all others, it is used and extended to represent fluid and rigid bodies More...
#include <Particle.h>
Public Member Functions | |
Particle () | |
ctor | |
Particle (const Particle &_particle) | |
copy ctor | |
Particle (const int _id, const ngl::Real _mass, const ngl::Vector _position, const ngl::Colour _colour, const ngl::Real _radius, const bool _moveable=true, const ngl::Vector _velocity=0, const ngl::Vector _acceleration=0, const ngl::Vector _netForce=0) | |
ctor | |
~Particle () | |
dtor | |
int | getId () const |
return the id | |
void | setId (const int _id) |
sets the id | |
ngl::Real | getMass () const |
return the mass | |
ngl::Vector | getLastPosition () const |
return the last position | |
ngl::Vector | getPosition () const |
return the current position | |
void | setPosition (const ngl::Vector _p) |
sets the position | |
void | updatePosition (const ngl::Vector _p) |
update the position to a new value | |
ngl::Vector | getLastVelocity () const |
return the last velocity | |
ngl::Vector | getVelocity () const |
return the current velocity | |
void | setVelocity (const ngl::Vector _v) |
sets the velocity | |
void | updateVelocity (const ngl::Vector _v) |
update the velocity to a new value | |
void | resetForce () |
reset all the forces | |
ngl::Vector | getNetForce () const |
return the net force | |
void | accumulateNetForce (const ngl::Vector _f) |
add in a force to the accumulated force | |
ngl::Vector | getLastAcceleration () const |
return the last acceleration | |
ngl::Vector | getAcceleration () const |
return the current acceleration | |
void | setAcceleration (const ngl::Vector _a) |
set the acceleration | |
void | updateAcceleration (const ngl::Vector _a) |
update the acceleration | |
bool | getMoveable () const |
return whether the particle is static | |
void | setMoveable (const bool _f) |
set a flag to determine whether the particle is static | |
ngl::Real | getRadius () const |
return the radius | |
void | setRadius (const ngl::Real _c) |
set the radius | |
ngl::Colour | getColour () const |
return the current colour | |
void | setColour (const ngl::Colour _c) |
set the colour | |
Protected Attributes | |
int | m_id |
unique id of the particle | |
ngl::Real | m_mass |
mass of the particle | |
ngl::Vector | m_lastPosition |
last position of the particle | |
ngl::Vector | m_position |
position of the particle | |
ngl::Vector | m_lastVelocity |
last velocity of the particle | |
ngl::Vector | m_velocity |
velocity of the particle | |
ngl::Vector | m_lastAcceleration |
last acceleration of the particle | |
ngl::Vector | m_acceleration |
acceleration of the particle | |
ngl::Vector | m_netForce |
net force on the particle | |
ngl::Real | m_moveable |
flag for moveability | |
ngl::Real | m_radius |
collision sphere radius | |
ngl::Colour | m_colour |
colour of particle for rendering |
base particle class to all others, it is used and extended to represent fluid and rigid bodies
Definition at line 20 of file Particle.h.
Particle::Particle | ( | ) |
Particle::Particle | ( | const Particle & | _particle | ) |
copy ctor
[in] | _particle | the copied object |
Definition at line 11 of file Particle.cpp.
References getAcceleration(), getColour(), getId(), getMass(), getMoveable(), getNetForce(), getPosition(), getRadius(), getVelocity(), m_acceleration, m_colour, m_id, m_lastAcceleration, m_lastPosition, m_lastVelocity, m_mass, m_moveable, m_netForce, m_position, m_radius, and m_velocity.
{ m_id = _particle.getId(); m_mass = _particle.getMass(); m_position = _particle.getPosition(); m_lastPosition = m_position; m_velocity = _particle.getVelocity(); m_lastVelocity = m_velocity; m_acceleration = _particle.getAcceleration(); m_lastAcceleration = m_acceleration; m_netForce = _particle.getNetForce(); m_moveable = _particle.getMoveable(); m_radius = _particle.getRadius(); m_colour = _particle.getColour(); }
Particle::Particle | ( | const int | _id, |
const ngl::Real | _mass, | ||
const ngl::Vector | _position, | ||
const ngl::Colour | _colour, | ||
const ngl::Real | _radius, | ||
const bool | _moveable = true , |
||
const ngl::Vector | _velocity = 0 , |
||
const ngl::Vector | _acceleration = 0 , |
||
const ngl::Vector | _netForce = 0 |
||
) |
ctor
[in] | _id | the id of the particle |
[in] | _mass | the mass of the particle |
[in] | _position | the position of the particle |
[in] | _colour | the colour of the particle |
[in] | _radius | the radius of the particle |
[in] | _moveable | flag to determine whether particle is static |
[in] | _velocity | the velocity of the particle |
[in] | _acceleration | the acceleration of the particle |
[in] | _netForce | the net force acting on the partcile |
Definition at line 36 of file Particle.cpp.
{ //init params m_id = _id; m_mass = _mass; m_position = _position; m_lastPosition = m_position; m_velocity = _velocity; m_lastVelocity = m_velocity; m_acceleration = _acceleration; m_lastAcceleration = m_acceleration; m_netForce = _netForce; m_moveable = _moveable; m_radius = _radius; m_colour = _colour; }
Particle::~Particle | ( | ) |
void Particle::accumulateNetForce | ( | const ngl::Vector | _f | ) | [inline] |
add in a force to the accumulated force
[in] | _f | the force to add |
Definition at line 102 of file Particle.h.
References m_netForce.
{ m_netForce += _f; }
ngl::Vector Particle::getAcceleration | ( | ) | const [inline] |
return the current acceleration
Definition at line 108 of file Particle.h.
References m_acceleration.
{ return m_acceleration; }
ngl::Colour Particle::getColour | ( | ) | const [inline] |
return the current colour
Definition at line 133 of file Particle.h.
References m_colour.
{ return m_colour; }
int Particle::getId | ( | ) | const [inline] |
return the id
Definition at line 57 of file Particle.h.
References m_id.
{ return m_id; }
ngl::Vector Particle::getLastAcceleration | ( | ) | const [inline] |
return the last acceleration
Definition at line 105 of file Particle.h.
References m_lastAcceleration.
{ return m_lastAcceleration; }
ngl::Vector Particle::getLastPosition | ( | ) | const [inline] |
return the last position
Definition at line 67 of file Particle.h.
References m_lastPosition.
{ return m_lastPosition; }
ngl::Vector Particle::getLastVelocity | ( | ) | const [inline] |
return the last velocity
Definition at line 81 of file Particle.h.
References m_lastVelocity.
{ return m_lastVelocity; }
ngl::Real Particle::getMass | ( | ) | const [inline] |
return the mass
Definition at line 64 of file Particle.h.
References m_mass.
{ return m_mass; }
bool Particle::getMoveable | ( | ) | const [inline] |
return whether the particle is static
Definition at line 119 of file Particle.h.
References m_moveable.
{ return m_moveable; }
ngl::Vector Particle::getNetForce | ( | ) | const [inline] |
return the net force
Definition at line 98 of file Particle.h.
References m_netForce.
{ return m_netForce; }
ngl::Vector Particle::getPosition | ( | ) | const [inline] |
return the current position
Definition at line 70 of file Particle.h.
References m_position.
{ return m_position; }
ngl::Real Particle::getRadius | ( | ) | const [inline] |
return the radius
Definition at line 126 of file Particle.h.
References m_radius.
{ return m_radius; }
ngl::Vector Particle::getVelocity | ( | ) | const [inline] |
return the current velocity
Definition at line 84 of file Particle.h.
References m_velocity.
{ return m_velocity; }
void Particle::resetForce | ( | ) | [inline] |
reset all the forces
Reimplemented in FluidParticle.
Definition at line 95 of file Particle.h.
References m_netForce.
{ m_netForce = 0; }
void Particle::setAcceleration | ( | const ngl::Vector | _a | ) |
set the acceleration
[in] | _a | the new acceleration |
Definition at line 107 of file Particle.cpp.
References m_acceleration, and m_lastAcceleration.
{ //set velocities to new value m_lastAcceleration = _a; m_acceleration = _a; }
void Particle::setColour | ( | const ngl::Colour | _c | ) | [inline] |
set the colour
[in] | _c | the new colour |
Definition at line 137 of file Particle.h.
References m_colour.
{ m_colour = _c; }
void Particle::setId | ( | const int | _id | ) | [inline] |
sets the id
[in] | _id | the id |
Definition at line 61 of file Particle.h.
References m_id.
{ m_id = _id; }
void Particle::setMoveable | ( | const bool | _f | ) | [inline] |
set a flag to determine whether the particle is static
[in] | _f | the flag to determine whether particle is static |
Definition at line 123 of file Particle.h.
References m_moveable.
{ m_moveable = _f; }
void Particle::setPosition | ( | const ngl::Vector | _p | ) |
sets the position
[in] | _p | the new position |
Definition at line 75 of file Particle.cpp.
References m_lastPosition, and m_position.
{ //set positions to new value m_lastPosition = _p; m_position = _p; }
void Particle::setRadius | ( | const ngl::Real | _c | ) | [inline] |
set the radius
[in] | _c | the radius |
Definition at line 130 of file Particle.h.
References m_radius.
{ m_radius = _c; }
void Particle::setVelocity | ( | const ngl::Vector | _v | ) |
sets the velocity
[in] | _v | the new velocity |
Definition at line 91 of file Particle.cpp.
References m_lastVelocity, and m_velocity.
{ //set velocities to new value m_lastVelocity = _v; m_velocity = _v; }
void Particle::updateAcceleration | ( | const ngl::Vector | _a | ) |
update the acceleration
[in] | _a | the new acceleration |
Definition at line 114 of file Particle.cpp.
References m_acceleration, and m_lastAcceleration.
{ //save current value m_lastAcceleration = m_acceleration; //update to new value m_acceleration = _a; }
void Particle::updatePosition | ( | const ngl::Vector | _p | ) |
update the position to a new value
[in] | _p | the new position |
Definition at line 82 of file Particle.cpp.
References m_lastPosition, and m_position.
{ //save current value m_lastPosition = m_position; //update to new value m_position = _p; }
void Particle::updateVelocity | ( | const ngl::Vector | _v | ) |
update the velocity to a new value
[in] | _v | the new velocity |
Definition at line 98 of file Particle.cpp.
References m_lastVelocity, and m_velocity.
{ //save current value m_lastVelocity = m_velocity; //update to new value m_velocity = _v; }
ngl::Vector Particle::m_acceleration [protected] |
acceleration of the particle
Definition at line 162 of file Particle.h.
ngl::Colour Particle::m_colour [protected] |
colour of particle for rendering
Definition at line 174 of file Particle.h.
int Particle::m_id [protected] |
unique id of the particle
Definition at line 141 of file Particle.h.
ngl::Vector Particle::m_lastAcceleration [protected] |
last acceleration of the particle
Definition at line 159 of file Particle.h.
ngl::Vector Particle::m_lastPosition [protected] |
last position of the particle
Definition at line 147 of file Particle.h.
ngl::Vector Particle::m_lastVelocity [protected] |
last velocity of the particle
Definition at line 153 of file Particle.h.
ngl::Real Particle::m_mass [protected] |
mass of the particle
Definition at line 144 of file Particle.h.
ngl::Real Particle::m_moveable [protected] |
flag for moveability
Definition at line 168 of file Particle.h.
ngl::Vector Particle::m_netForce [protected] |
net force on the particle
Definition at line 165 of file Particle.h.
ngl::Vector Particle::m_position [protected] |
position of the particle
Definition at line 150 of file Particle.h.
ngl::Real Particle::m_radius [protected] |
collision sphere radius
Definition at line 171 of file Particle.h.
ngl::Vector Particle::m_velocity [protected] |
velocity of the particle
Definition at line 156 of file Particle.h.