AnimaL |
Tutorial |
Documentation |
#include <simplesolver.h>
Inheritance diagram for animal::SimpleSolver< 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 42 of file simplesolver.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 | |
SimpleSolver () | |
Default constructor. | |
virtual | ~SimpleSolver () |
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 | solveODE (Positions &p, 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. | |
Protected Types | |
typedef OdeSolver< t_Positions, t_Vector, t_Real > | Parent |
parent class | |
Static Protected Member Functions | |
Vec | zero () |
The null elementary vector. | |
Protected Attributes | |
Vec | _gravity |
Value of the gravity applied to the objects. | |
bool | _useGravity |
Apply gravity or not. | |
Real | _exponentialDamping |
Value of the exponential damping. | |
const 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 53 of file simplesolver.h. |
|
array of inverses masses
Definition at line 52 of file simplesolver.h. |
|
parent class
Definition at line 120 of file simplesolver.h. |
|
Vector of positions.
Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 49 of file simplesolver.h. |
|
time and other scalar values
Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 54 of file simplesolver.h. |
|
a basic vector (velocity, force, etc)
Definition at line 51 of file simplesolver.h. |
|
velocities, forces, accelerations
Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 50 of file simplesolver.h. |
|
Default constructor. All booleans are initially false and values are null. Definition at line 26 of file simplesolver.inl. |
|
Definition at line 33 of file simplesolver.inl. |
|
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. |
|
Add gravity to the given accelerations, except those of fixed particles.
Definition at line 94 of file simplesolver.inl. References animal::size(), animal::v_addall(), and animal::v_peq(). |
|
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. Implements animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 117 of file simplesolver.inl. |
|
Add forces to the current force vector. This base method sets all forces to zero(). Definition at line 178 of file simplesolver.inl. References animal::v_assign(). |
|
Read property of Real _exponentialDamping.
Definition at line 79 of file simplesolver.inl. |
|
Read property of Vec _gravity.
Definition at line 39 of file simplesolver.inl. |
|
Read property of InvMasses* _invMasses.
Definition at line 223 of file simplesolver.inl. |
|
Read property of InvMass _singleInvMass.
Definition at line 209 of file simplesolver.inl. |
|
Read property of bool _useExponentialDamping.
Definition at line 65 of file simplesolver.inl. |
|
Read property of bool _useGravity.
Definition at line 53 of file simplesolver.inl. |
|
Read property of bool _useMass.
Definition at line 184 of file simplesolver.inl. |
|
Read property of bool _useSingleMass.
Definition at line 196 of file simplesolver.inl. |
|
Write property of Real _exponentialDamping. After ODE solution, all velocities are uniformly scaled (see class description) Definition at line 85 of file simplesolver.inl. |
|
Write property of Vec _gravity.
Definition at line 46 of file simplesolver.inl. |
|
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 229 of file simplesolver.inl. |
|
Write property of InvMass _singleInvMass.
Definition at line 215 of file simplesolver.inl. |
|
Write property of bool _useExponentialDamping. If true, damping is applied. Definition at line 71 of file simplesolver.inl. |
|
Write property of bool _useGravity.
Definition at line 59 of file simplesolver.inl. |
|
Write property of bool _useMass. If false, mass is not used and the forces are used as accelerations. Definition at line 190 of file simplesolver.inl. |
|
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 202 of file simplesolver.inl. |
|
Applies parent class method, then scale the velocities accordingly with exponential damping.
Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >. Definition at line 164 of file simplesolver.inl. References animal::v_teq(). |
|
The null elementary vector.
Definition at line 134 of file simplesolver.h. |
|
Value of the exponential damping.
Definition at line 126 of file simplesolver.h. |
|
Value of the gravity applied to the objects.
Definition at line 122 of file simplesolver.h. |
|
Pointer to the array of inverse masses (one for each object).
Definition at line 128 of file simplesolver.h. |
|
The common mass value.
Definition at line 132 of file simplesolver.h. |
|
Apply exponential damping or not.
Definition at line 130 of file simplesolver.h. |
|
Apply gravity or not.
Definition at line 124 of file simplesolver.h. |
|
Use mass(es) or not. If not, the forces are used as accelerations, as well as gravity. Definition at line 136 of file simplesolver.h. |
|
Assume the same mass for all the objects.
Definition at line 138 of file simplesolver.h. |