Documentation


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

#include <physicalSolver.h>

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

animal::MassSpringSolver< t_Positions, t_Vector, t_InvMasses, t_VecReal, t_VecIndex > animal::MassSpringSolver< Points, Velocities, Inv_Masses, SpringStiffness, IndexedSprings > animal::MassSpringSolver< X3DTK::MFVec3f, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFFloat, X3DTK::MFInt32 > animal::MassSpringEngine< X3DTK::MFFloat, X3DTK::MFVec3f, X3DTK::MFFloat, X3DTK::MFInt32, X3DTK::MFVec3f, float > animal::MassSpringEngine< Inv_Masses, Velocities, SpringStiffness, IndexedSprings, Points, Real > X3DTK::X3D::AnimalEngineNode< AMassSpringEngine > X3DTK::X3D::MassSpringNode List of all members.

Detailed Description

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
class animal::PhysicalSolver< 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 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 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.


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.


Member Typedef Documentation

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

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

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

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

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

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.

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

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.

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

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.

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

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.


Constructor & Destructor Documentation

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

Default constructor.

All booleans are initially false and values are null.

Definition at line 26 of file physicalSolver.inl.

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

Definition at line 37 of file physicalSolver.inl.


Member Function Documentation

template<class P, class V, class I, class R>
void animal::PhysicalSolver< P, V, I, R >::applyExponentialDamping Vector v,
Real  dt
 

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

template<class P, class V, class I, class R>
void animal::PhysicalSolver< P, V, I, R >::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.

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

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

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

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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.

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.

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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().

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

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

Read property of Real _exponentialDamping.

Definition at line 85 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt().

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

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

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

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.

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

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.

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

Read property of bool _useExponentialDamping.

Definition at line 71 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt().

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

Read property of bool _useGravity.

Definition at line 59 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::MassSpringEngineQt().

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

Read property of bool _useMass.

Definition at line 189 of file physicalSolver.inl.

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

Read property of bool _useSingleMass.

Definition at line 201 of file physicalSolver.inl.

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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 91 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::setExponentialDamping().

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

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

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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 234 of file physicalSolver.inl.

References animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::InvMasses.

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

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.

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

Write property of bool _useExponentialDamping.

If true, damping is applied.

Definition at line 77 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::toggleExponentialDamping().

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

Write property of bool _useGravity.

Definition at line 65 of file physicalSolver.inl.

Referenced by X3DTK::Qt::MassSpringEngineQt::toggleGravity().

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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 195 of file physicalSolver.inl.

Referenced by X3DTK::X3D::MassSpringNode::init().

template<class P, class V, class I, class R>
void animal::PhysicalSolver< 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 207 of file physicalSolver.inl.

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

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


Member Data Documentation

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
Real animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_exponentialDamping
 

Value of the exponential damping.

Definition at line 128 of file physicalSolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
Vec animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_gravity
 

Value of the gravity applied to the objects.

Definition at line 124 of file physicalSolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
InvMasses* animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_invMasses
 

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

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
InvMass animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_singleInvMass
 

The common mass value.

Definition at line 134 of file physicalSolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useExponentialDamping
 

Apply exponential damping or not.

Definition at line 132 of file physicalSolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useGravity
 

Apply gravity or not.

Definition at line 126 of file physicalSolver.h.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useMass
 

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.

template<class t_Positions, class t_Vector, class t_InvMasses, class t_Real>
bool animal::PhysicalSolver< t_Positions, t_Vector, t_InvMasses, t_Real >::_useSingleMass
 

Assume the same mass for all the objects.

Definition at line 140 of file physicalSolver.h.


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