AnimaL |
Tutorial |
Documentation |
#include <physicalSolver.h>
Inheritance diagram for animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >:
Virtual method computeForces( Vector&, const Positions&, const Vector& ) just initializes the forces to zero. You may derive it to implement your forces. This is the only method you need to derive.
Method computeAcceleration( Vector& acc, const Positions& pos, const Vector& vel ) compute the forces then the accelerations.
Mass can be used or not by setting void set_useMass(const bool&). A unique mass can be used, or a different value for each object (see void set_useSingleMass( const bool&), void set_singleInvMass( const InvMass& _newVal) and void set_invMasses( InvMasses* _newVal)). Inverse masses are used rather than masses for two reasons:
Gravity can be applied or not, depending on void set_useGravity( const bool&).
ODE solution from parent class is applied, then a simplified version of air damping is used to decrease velocities. Exponential damping is applied isotropically and regardless of the mass or size of objects. After each integration step, the velocities are multiplied by where
is the value of member _exponentialDamping.
Definition at line 43 of file physicalSolver.h.
Public Types | |
typedef t_Positions | Positions |
Vector of positions. | |
typedef t_Vector | Vector |
velocities, forces, accelerations | |
typedef container_traits< Vector >::value_type | Vec |
a basic vector (velocity, force, etc) | |
typedef t_InvMasses | InvMasses |
array of inverses masses | |
typedef container_traits< InvMasses >::value_type | InvMass |
typedef t_Real | Real |
time and other scalar values | |
Public Member Functions | |
PhysicalSolver () | |
Default constructor. | |
virtual | ~PhysicalSolver () |
virtual void | computeAccelerations (Vector &acc, const Positions &pos, const Vector &vel) |
Compute the accelerations of the points based on their positions and velocities. | |
virtual void | applyForces (Vector &acc, const Vector &forces) |
Compute the accelerations of the points based on their net forces. | |
void | applyExponentialDamping (Vector &v, Real dt) |
Applies parent class method, then scale the velocities accordingly with exponential damping. | |
virtual void | computeForces (Vector &acc, const Positions &pos, const Vector &vel) |
Add forces to the current force vector. | |
gravity | |
virtual void | set_gravity (const Vec &_newVal) |
Write property of Vec _gravity. | |
virtual const Vec & | get_gravity () |
Read property of Vec _gravity. | |
virtual void | set_useGravity (const bool &_newVal) |
Write property of bool _useGravity. | |
virtual const bool & | get_useGravity () |
Read property of bool _useGravity. | |
void | applyGravity (Vector &a) |
Add gravity to the given accelerations, except those of fixed particles. | |
exponential air damping | |
virtual void | set_useExponentialDamping (const bool &_newVal) |
Write property of bool _useExponentialDamping. | |
virtual const bool & | get_useExponentialDamping () |
Read property of bool _useExponentialDamping. | |
virtual void | set_exponentialDamping (const Real &_newVal) |
Write property of Real _exponentialDamping. | |
virtual const Real & | get_exponentialDamping () |
Read property of Real _exponentialDamping. | |
mass | |
virtual void | set_useMass (const bool &_newVal) |
Write property of bool _useMass. | |
virtual const bool & | get_useMass () |
Read property of bool _useMass. | |
virtual void | set_useSingleMass (const bool &_newVal) |
Write property of bool _useSingleMass. | |
virtual const bool & | get_useSingleMass () |
Read property of bool _useSingleMass. | |
virtual void | set_singleInvMass (const InvMass &_newVal) |
Write property of InvMass _singleInvMass. | |
virtual const InvMass & | get_singleInvMass () |
Read property of InvMass _singleInvMass. | |
virtual void | set_invMasses (InvMasses *_newVal) |
Write property of InvMasses* _invMasses. | |
virtual const InvMasses * | get_invMasses () |
Read property of InvMasses* _invMasses. | |
Static Public Member Functions | |
Vec | zero () |
The null elementary vector. | |
Public Attributes | |
Vec | _gravity |
Value of the gravity applied to the objects. | |
bool | _useGravity |
Apply gravity or not. | |
Real | _exponentialDamping |
Value of the exponential damping. | |
InvMasses * | _invMasses |
Pointer to the array of inverse masses (one for each object). | |
bool | _useExponentialDamping |
Apply exponential damping or not. | |
InvMass | _singleInvMass |
The common mass value. | |
bool | _useMass |
Use mass(es) or not. | |
bool | _useSingleMass |
Assume the same mass for all the objects. |
|
Definition at line 54 of file physicalSolver.h. Referenced by animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::get_singleInvMass(), and animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::set_singleInvMass(). |
|
array of inverses masses
Definition at line 53 of file physicalSolver.h. Referenced by animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::get_invMasses(), and animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::set_invMasses(). |
|
Vector of positions.
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 50 of file physicalSolver.h. |
|
time and other scalar values
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 55 of file physicalSolver.h. |
|
a basic vector (velocity, force, etc)
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 52 of file physicalSolver.h. |
|
velocities, forces, accelerations
Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 51 of file physicalSolver.h. |
|
Default constructor. All booleans are initially false and values are null. Definition at line 26 of file physicalSolver.inl. |
|
Definition at line 37 of file physicalSolver.inl. |
|
Applies parent class method, then scale the velocities accordingly with exponential damping.
Definition at line 172 of file physicalSolver.inl. References animal::v_teq(). Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::solveODE(). |
|
Compute the accelerations of the points based on their net forces. If masses are applied (set_useMass( const bool& ) set to true) then the forces are multiplied by the inverse masses else the forces are directly used as accelerations. If gravity is applied (set_useGravity( const bool& ) set to true) then gravity is then added to the accelerations. If masses are used, then gravity is not applied to objects with null inverse masses. Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 144 of file physicalSolver.inl. References animal::size(), animal::v_eq(), and animal::v_eq_ab(). |
|
Add gravity to the given accelerations, except those of fixed particles.
Definition at line 102 of file physicalSolver.inl. References animal::size(), animal::v_addall(), and animal::v_peq(). Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::computeAccelerationsAndStiffness(). |
|
Compute the accelerations of the points based on their positions and velocities. If masses are applied (set_useMass( const bool& ) set to true) then the forces are multiplied by the inverse masses else the forces are directly used as accelerations. If gravity is applied (set_useGravity( const bool& ) set to true) then gravity is then added to the accelerations. If masses are used, then gravity is not applied to objects with null inverse masses. Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 125 of file physicalSolver.inl. |
|
Add forces to the current force vector. This base method sets all forces to zero(). Reimplemented in animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >, animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings >, and animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 >. Definition at line 183 of file physicalSolver.inl. References animal::v_assign(). |
|
Read property of Real _exponentialDamping.
Definition at line 85 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt(). |
|
Read property of Vec _gravity.
Definition at line 45 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt(), X3DTK::Qt::MassSpringEngineQt::setXgravity(), X3DTK::Qt::MassSpringEngineQt::setYgravity(), and X3DTK::Qt::MassSpringEngineQt::setZgravity(). |
|
Read property of InvMasses* _invMasses.
Definition at line 228 of file physicalSolver.inl. References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMasses. |
|
Read property of InvMass _singleInvMass.
Definition at line 214 of file physicalSolver.inl. References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMass. |
|
Read property of bool _useExponentialDamping.
Definition at line 71 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt(). |
|
Read property of bool _useGravity.
Definition at line 59 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt(). |
|
Read property of bool _useMass.
Definition at line 189 of file physicalSolver.inl. |
|
Read property of bool _useSingleMass.
Definition at line 201 of file physicalSolver.inl. |
|
Write property of Real _exponentialDamping. After ODE solution, all velocities are uniformly scaled (see class description) Definition at line 91 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::setExponentialDamping(). |
|
Write property of Vec _gravity.
Definition at line 52 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::setXgravity(), X3DTK::Qt::MassSpringEngineQt::setYgravity(), and X3DTK::Qt::MassSpringEngineQt::setZgravity(). |
|
Write property of InvMasses* _invMasses. This is the array of inverse masses, one per particle. A null value means a fixed point. Definition at line 234 of file physicalSolver.inl. References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMasses. |
|
Write property of InvMass _singleInvMass.
Definition at line 220 of file physicalSolver.inl. References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMass. |
|
Write property of bool _useExponentialDamping. If true, damping is applied. Definition at line 77 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::toggleExponentialDamping(). |
|
Write property of bool _useGravity.
Definition at line 65 of file physicalSolver.inl. Referenced by X3DTK::Qt::MassSpringEngineQt::toggleGravity(). |
|
Write property of bool _useMass. If false, mass is not used and the forces are used as accelerations. Definition at line 195 of file physicalSolver.inl. Referenced by X3DTK::X3D::MassSpringNode::init(). |
|
Write property of bool _useSingleMass. If true, it is assumed that all the particles have the same mass defined using method set_singleInvMass( const InvMass& _newVal). Definition at line 207 of file physicalSolver.inl. |
|
The null elementary vector.
Definition at line 136 of file physicalSolver.h. Referenced by animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex >::v_eq_h_dfdx_x(). |
|
Value of the exponential damping.
Definition at line 128 of file physicalSolver.h. |
|
Value of the gravity applied to the objects.
Definition at line 124 of file physicalSolver.h. |
|
Pointer to the array of inverse masses (one for each object).
Definition at line 130 of file physicalSolver.h. Referenced by animal::MassSpringEngine< Inv_Masses, Velocities, SpringStiffness, IndexedSprings, Points, Real >::ConstrainedPoint::moveTo(), and animal::MassSpringEngine< Inv_Masses, Velocities, SpringStiffness, IndexedSprings, Points, Real >::ConstrainedPoint::~ConstrainedPoint(). |
|
The common mass value.
Definition at line 134 of file physicalSolver.h. |
|
Apply exponential damping or not.
Definition at line 132 of file physicalSolver.h. |
|
Apply gravity or not.
Definition at line 126 of file physicalSolver.h. |
|
Use mass(es) or not. If not, the forces are used as accelerations, as well as gravity. Definition at line 138 of file physicalSolver.h. |
|
Assume the same mass for all the objects.
Definition at line 140 of file physicalSolver.h. |