Documentation


animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real > Class Template Reference

#include <simplesolver.h>

Inheritance diagram for animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >:

animal::OdeSolver< t_Positions, t_Vector, t_Real > List of all members.

Detailed Description

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
class animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >

This is a base class for physically-based animation of points (gravity, air damping).

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 $ \exp( -\nu t ) $ where $ \nu $ is the value of member _exponentialDamping.

Author:
François Faure

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 Vecget_gravity ()
 Read property of Vec _gravity.

virtual void set_useGravity (const bool &_newVal)
 Write property of bool _useGravity.

virtual const boolget_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 boolget_useExponentialDamping ()
 Read property of bool _useExponentialDamping.

virtual void set_exponentialDamping (const Real &_newVal)
 Write property of Real _exponentialDamping.

virtual const Realget_exponentialDamping ()
 Read property of Real _exponentialDamping.

mass
virtual void set_useMass (const bool &_newVal)
 Write property of bool _useMass.

virtual const boolget_useMass ()
 Read property of bool _useMass.

virtual void set_useSingleMass (const bool &_newVal)
 Write property of bool _useSingleMass.

virtual const boolget_useSingleMass ()
 Read property of bool _useSingleMass.

virtual void set_singleInvMass (const InvMass &_newVal)
 Write property of InvMass _singleInvMass.

virtual const InvMassget_singleInvMass ()
 Read property of InvMass _singleInvMass.

virtual void set_invMasses (InvMasses *_newVal)
 Write property of InvMasses* _invMasses.

virtual const InvMassesget_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.


Member Typedef Documentation

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef container_traits<InvMasses>::value_type animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMass
 

Definition at line 53 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef t_InvMasses animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMasses
 

array of inverses masses

Definition at line 52 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef OdeSolver<t_Positions,t_Vector,t_Real> animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::Parent [protected]
 

parent class

Definition at line 120 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef t_Positions animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::Positions
 

Vector of positions.

Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >.

Definition at line 49 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef t_Real animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::Real
 

time and other scalar values

Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >.

Definition at line 54 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef container_traits<Vector>::value_type animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::Vec
 

a basic vector (velocity, force, etc)

Definition at line 51 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
typedef t_Vector animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::Vector
 

velocities, forces, accelerations

Reimplemented from animal::OdeSolver< t_Positions, t_Vector, t_Real >.

Definition at line 50 of file simplesolver.h.


Constructor & Destructor Documentation

template<class P, class V, class I, class R>
animal::SimpleSolver< P, V, I, R >::SimpleSolver  ) 
 

Default constructor.

All booleans are initially false and values are null.

Definition at line 26 of file simplesolver.inl.

template<class P, class V, class I, class R>
animal::SimpleSolver< P, V, I, R >::~SimpleSolver  )  [virtual]
 

Definition at line 33 of file simplesolver.inl.


Member Function Documentation

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
virtual void animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::applyForces Vector acc,
const Vector forces
[virtual]
 

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.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::applyGravity Vector acc  ) 
 

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().

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::computeAccelerations Vector acc,
const Positions pos,
const Vector vel
[virtual]
 

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.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::computeForces Vector acc,
const Positions pos,
const Vector vel
[virtual]
 

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().

template<class P, class V, class I, class R>
const SimpleSolver< P, V, I, R >::Real & animal::SimpleSolver< P, V, I, R >::get_exponentialDamping  )  [virtual]
 

Read property of Real _exponentialDamping.

Definition at line 79 of file simplesolver.inl.

template<class P, class V, class I, class R>
const SimpleSolver< P, V, I, R >::Vec & animal::SimpleSolver< P, V, I, R >::get_gravity  )  [virtual]
 

Read property of Vec _gravity.

Definition at line 39 of file simplesolver.inl.

template<class P, class V, class I, class R>
const SimpleSolver< P, V, I, R >::InvMasses * animal::SimpleSolver< P, V, I, R >::get_invMasses  )  [virtual]
 

Read property of InvMasses* _invMasses.

Definition at line 223 of file simplesolver.inl.

template<class P, class V, class I, class R>
const SimpleSolver< P, V, I, R >::InvMass & animal::SimpleSolver< P, V, I, R >::get_singleInvMass  )  [virtual]
 

Read property of InvMass _singleInvMass.

Definition at line 209 of file simplesolver.inl.

template<class P, class V, class I, class R>
const bool & animal::SimpleSolver< P, V, I, R >::get_useExponentialDamping  )  [virtual]
 

Read property of bool _useExponentialDamping.

Definition at line 65 of file simplesolver.inl.

template<class P, class V, class I, class R>
const bool & animal::SimpleSolver< P, V, I, R >::get_useGravity  )  [virtual]
 

Read property of bool _useGravity.

Definition at line 53 of file simplesolver.inl.

template<class P, class V, class I, class R>
const bool & animal::SimpleSolver< P, V, I, R >::get_useMass  )  [virtual]
 

Read property of bool _useMass.

Definition at line 184 of file simplesolver.inl.

template<class P, class V, class I, class R>
const bool & animal::SimpleSolver< P, V, I, R >::get_useSingleMass  )  [virtual]
 

Read property of bool _useSingleMass.

Definition at line 196 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_exponentialDamping const Real _newVal  )  [virtual]
 

Write property of Real _exponentialDamping.

After ODE solution, all velocities are uniformly scaled (see class description)

Definition at line 85 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_gravity const Vec _newVal  )  [virtual]
 

Write property of Vec _gravity.

Definition at line 46 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_invMasses InvMasses _newVal  )  [virtual]
 

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.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_singleInvMass const InvMass _newVal  )  [virtual]
 

Write property of InvMass _singleInvMass.

Definition at line 215 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_useExponentialDamping const bool _newVal  )  [virtual]
 

Write property of bool _useExponentialDamping.

If true, damping is applied.

Definition at line 71 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_useGravity const bool _newVal  )  [virtual]
 

Write property of bool _useGravity.

Definition at line 59 of file simplesolver.inl.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_useMass const bool _newVal  )  [virtual]
 

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.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::set_useSingleMass const bool _newVal  )  [virtual]
 

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.

template<class P, class V, class I, class R>
void animal::SimpleSolver< P, V, I, R >::solveODE Positions p,
Vector v,
Real  dt
[virtual]
 

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().

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
Vec animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::zero  )  [inline, static, protected]
 

The null elementary vector.

Definition at line 134 of file simplesolver.h.


Member Data Documentation

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
Real animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_exponentialDamping [protected]
 

Value of the exponential damping.

Definition at line 126 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
Vec animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_gravity [protected]
 

Value of the gravity applied to the objects.

Definition at line 122 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
const InvMasses* animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_invMasses [protected]
 

Pointer to the array of inverse masses (one for each object).

Definition at line 128 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
InvMass animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_singleInvMass [protected]
 

The common mass value.

Definition at line 132 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useExponentialDamping [protected]
 

Apply exponential damping or not.

Definition at line 130 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useGravity [protected]
 

Apply gravity or not.

Definition at line 124 of file simplesolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useMass [protected]
 

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.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::SimpleSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useSingleMass [protected]
 

Assume the same mass for all the objects.

Definition at line 138 of file simplesolver.h.


The documentation for this class was generated from the following files:
Generated on Thu Dec 23 13:52:31 2004 by doxygen 1.3.6