Public Member Functions

RK4Spring Class Reference

this class implements a simple dampped spring system using RK4 integration the main motionFunction is derived from http://gafferongames.com/game-physics/spring-physics/ More...

#include <RK4Spring.h>

List of all members.

Public Member Functions

 RK4Spring (ngl::Vector _a, ngl::Vector _b, float _length, float _k, float _damping)
 ctor
void update ()
 this method calls the integrator to calculate the spring force and updates the spring points, if the points are fixed then no update is made to the points
void setTimeStep (float _t)
 accessor to set the integration time step (dt)
ngl::Vector motionFunction (const State &_state, float _t)
 this is going to calculate the spring function F = -k(|x|-d)(x/|x|) - bv where k is the spring constant |x| is the distance between the two spring points d is the distance of seperation b is the coefficient of damping larger b increases the damping force v is the relative velocity between the spring points
void setAPosition (const ngl::Vector &_a)
 mutator to set the a position of the spring
void setBPosition (const ngl::Vector &_b)
 mutator to set the b position of the spring
ngl::Vector getAPosition () const
 accesor for the spring a position
ngl::Vector getBPosition () const
 accesor for the spring b position
ngl::Vector getInitialAPosition () const
 accesor for the spring initial a position
ngl::Vector getInitialBPosition () const
 accesor for the spring initial b position
void setK (float _k)
 mutator to set the spring constant k
void setLength (float _l)
 mutator to set the spring resting length
void setDamping (float _d)
 mutator to set the spring damping co-efficient
void setAFixed (bool _f)
 mutator to set if the point a is fixed and should not be updated
void setBFixed (bool _f)
 mutator to set if the point b is fixed and should not be updated
void reset ()
 re-set the simulation, this will return a and b to the initial values and re-set the time value m_t to 0

Detailed Description

this class implements a simple dampped spring system using RK4 integration the main motionFunction is derived from http://gafferongames.com/game-physics/spring-physics/


Constructor & Destructor Documentation

RK4Spring::RK4Spring ( ngl::Vector  _a,
ngl::Vector  _b,
float  _length,
float  _k,
float  _damping 
)

ctor

Parameters:
[in] _a the start position of spring point a-/\/\/\/
[in] _b the start position of spring point -/\/\/\/-b
[in] _length the resting length of the spring
[in] _k the spring constant from Hooke's law
[in] _damping the damping co-efficient of the spring

Member Function Documentation

ngl::Vector RK4Spring::getAPosition (  )  const [inline]

accesor for the spring a position

Returns:
m_a the current spring position
ngl::Vector RK4Spring::getBPosition (  )  const [inline]

accesor for the spring b position

Returns:
m_b the current spring position
ngl::Vector RK4Spring::getInitialAPosition (  )  const [inline]

accesor for the spring initial a position

Returns:
m_initialA the current spring position
ngl::Vector RK4Spring::getInitialBPosition (  )  const [inline]

accesor for the spring initial b position

Returns:
m_initialB the current spring position
ngl::Vector RK4Spring::motionFunction ( const State &  _state,
float  _t 
)

this is going to calculate the spring function F = -k(|x|-d)(x/|x|) - bv where k is the spring constant |x| is the distance between the two spring points d is the distance of seperation b is the coefficient of damping larger b increases the damping force v is the relative velocity between the spring points

Parameters:
[in] _state the state of the spring values to calculate
[in] _t the current time state
Returns:
a vector of the force calculated via the RK4 integrator
void RK4Spring::setAFixed ( bool  _f  )  [inline]

mutator to set if the point a is fixed and should not be updated

Parameters:
[in] _f the new value for the point a
void RK4Spring::setAPosition ( const ngl::Vector &  _a  )  [inline]

mutator to set the a position of the spring

Parameters:
[in] _a the value to set
void RK4Spring::setBFixed ( bool  _f  )  [inline]

mutator to set if the point b is fixed and should not be updated

Parameters:
[in] _f the new value for the point b
void RK4Spring::setBPosition ( const ngl::Vector &  _b  )  [inline]

mutator to set the b position of the spring

Parameters:
[in] _b the value to set
void RK4Spring::setDamping ( float  _d  )  [inline]

mutator to set the spring damping co-efficient

Parameters:
[in] _d the new damping value
void RK4Spring::setK ( float  _k  )  [inline]

mutator to set the spring constant k

Parameters:
[in] _k the new k value
void RK4Spring::setLength ( float  _l  )  [inline]

mutator to set the spring resting length

Parameters:
[in] _l the new resting length value
void RK4Spring::setTimeStep ( float  _t  )  [inline]

accessor to set the integration time step (dt)

Parameters:
[in] _t the time step value to use

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables