Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ani::Body Class Reference

Body, for use in a rigid body dynamics system. More...

#include <Body.h>

Inheritance diagram for ani::Body:

ani::Memory ani::DynamicSystem< ani::Body > ani::FireParticle gator::TravelMethod gator::Car4WheelsMethod gator::SimpleFlyMethod gator::TetheredDriveMethod gator::SimpleDriveMethod List of all members.

Public Methods

 Body ()
 Body (const Body &p)
virtual ~Body ()
void setParticle (bool val=false)
Body & operator= (const Body &p)
virtual void copy (const Body &p)
 this = p copies all attributes. More...

virtual void computeDerivative (const Body &currentState, const float &currentTime)
 computeDerivative. More...

virtual void normalize ()
const gmtl::Point3f & position () const
 "phase space" (see note above). More...

const gmtl::Quatf & rotation () const
gmtl::Vec3f linearVelocity () const
 Calculate v(t). More...

gmtl::Vec3f angularVelocity (const gmtl::Matrix44f &ws_tensor_inv) const
 Calculate w(t) using given inertia tensor w(t) = I^-1(t) L(t). More...

gmtl::Vec3f angularVelocity () const
 Calculate w(t), calcs the inertia tensor for you. More...

gmtl::Vec3f linearMomentum () const
gmtl::Vec3f angularMomentum () const
const gmtl::Vec3f & accumulatedForce () const
 other things needed by ODE to compute changes in the "phase space". More...

const gmtl::Vec3f & accumulatedTorque () const
const float & mass () const
const gmtl::Vec3f & volume () const
PhaseSpaceOperations
virtual void multiplyPhase (const Body &a, float h)
 scale by time. More...

virtual void multiplyPhase (float h)
 scale by time. More...

virtual void addPhase (const Body &a, const Body &b)
 phase space addition operator this = a + b. More...

virtual void addPhase (const Body &a)
 phase space addition operator this += a. More...

State Setting Accumulation
void setPosition (const gmtl::Point3f &position)
void setVelocity (const gmtl::Vec3f &velocity)
void setRotation (const gmtl::Quatf &rot)
void setAngularVelocity (gmtl::Vec3f &angularVel)
 set angular momentum with the given angular velocity calculate L(t), if w(t) is known... More...

void applyForce (const gmtl::Vec3f &force)
 Apply a force to the particle Each call to applyForce adds a force vector and torque to the particle. More...

void applyForce (const gmtl::Vec3f &force, const gmtl::Vec3f &location, const gmtl::Vec3f &center=gmtl::Vec3f(0.0f, 0.0f, 0.0f))
 apply a force to a position on the body. More...

void applyTorque (const gmtl::Vec3f &torque)
 Apply a torque to the particle torque is the axis of spin |torque| is the magnitude (i.e. More...

virtual void zeroForce ()
void setMass (const float &kilograms)
 set the mass units are metric kilograms. More...

void setVolume (gmtl::Vec3f vol)

Public Attributes

gmtl::Point3f mPosition
gmtl::Quatf mRotation
gmtl::Vec3f mLinearMomentum
gmtl::Vec3f mAngularMomentum
gmtl::Vec3f mForceAccumulator
gmtl::Vec3f mTorqueAccumulator
float mMass
float mInvMass
gmtl::Vec3f mVolume
gmtl::Matrix44f mBodySpaceInertiaTensor
gmtl::Matrix44f mBodySpaceInertiaTensorInv
float mDragCoef
bool mParticle

Detailed Description

Body, for use in a rigid body dynamics system.

Body is able to do newtonian physics through application of force and torque.

See also:
DynamicSystem , Operator , ODEsolver
Notes on "phase space" The motion of a newtonian particle is governed by the familiar f = ma, or, as we will write it here x'' = a = f/m. This equation differs from a canonical ODE because it involves a second time derivative, making it a _second_order_ equation. To handle a second order ODE, we convert it to a first order one by introducing extra variables. Here we create a variable mVelocity to represent velocity, giving us a pair of coupled first order ODE's: v' = f/m, and x' = v. This position/velocity product space is called _phase_space_.

Definition at line 102 of file Body.h.


Constructor & Destructor Documentation

ani::Body::Body   [inline]
 

Definition at line 105 of file Body.h.

References mAngularMomentum, mBodySpaceInertiaTensor, mBodySpaceInertiaTensorInv, mForceAccumulator, mInvMass, mLinearMomentum, mMass, mParticle, mPosition, mRotation, mTorqueAccumulator, and mVolume.

Referenced by gator::TravelMethod::TravelMethod().

ani::Body::Body const Body &    p [inline]
 

Definition at line 123 of file Body.h.

References copy().

virtual ani::Body::~Body   [inline, virtual]
 

Definition at line 128 of file Body.h.


Member Function Documentation

void ani::Body::setParticle bool    val = false [inline]
 

Definition at line 132 of file Body.h.

References mParticle.

Referenced by ani::FireParticle::FireParticle().

Body& ani::Body::operator= const Body &    p [inline]
 

Definition at line 137 of file Body.h.

References copy().

virtual void ani::Body::copy const Body &    p [inline, virtual]
 

this = p copies all attributes.

Definition at line 146 of file Body.h.

References mAngularMomentum, mBodySpaceInertiaTensor, mBodySpaceInertiaTensorInv, mForceAccumulator, mInvMass, mLinearMomentum, mMass, mParticle, mPosition, mRotation, mTorqueAccumulator, and mVolume.

Referenced by Body(), and operator=().

virtual void ani::Body::computeDerivative const Body &    currentState,
const float &    currentTime
[inline, virtual]
 

computeDerivative.

The behavior of the system is described by an "Ordinary Differential Equation" (ODE) of the form x' = f( x, t ) where f is a known function, x is the state of the system and x' is the time derivitive of x.

Here, f = computeDerivative, x' = this, and x = currentState; This function computes change due to the force accumulator The x' returned assumes time=1, so for example using Euler's method to solve the next step, you will have to scale x' by the amount of time since this func was last called.

Postcondition:
sets this to the time derivitive of "currentState"

Definition at line 187 of file Body.h.

References angularVelocity(), linearVelocity(), mAngularMomentum, mForceAccumulator, mLinearMomentum, mParticle, mPosition, mRotation, and mTorqueAccumulator.

virtual void ani::Body::normalize   [inline, virtual]
 

Definition at line 211 of file Body.h.

References mParticle, and mRotation.

virtual void ani::Body::multiplyPhase const Body &    a,
float    h
[inline, virtual]
 

scale by time.

this = a * h

Definition at line 225 of file Body.h.

References mAngularMomentum, mLinearMomentum, mParticle, mPosition, and mRotation.

virtual void ani::Body::multiplyPhase float    h [inline, virtual]
 

scale by time.

this *= h

Definition at line 240 of file Body.h.

References mAngularMomentum, mLinearMomentum, mParticle, mPosition, and mRotation.

virtual void ani::Body::addPhase const Body &    a,
const Body &    b
[inline, virtual]
 

phase space addition operator this = a + b.

Definition at line 255 of file Body.h.

References mAngularMomentum, mLinearMomentum, mParticle, mPosition, and mRotation.

virtual void ani::Body::addPhase const Body &    a [inline, virtual]
 

phase space addition operator this += a.

Definition at line 270 of file Body.h.

References mAngularMomentum, mLinearMomentum, mParticle, mPosition, and mRotation.

void ani::Body::setPosition const gmtl::Point3f &    position [inline]
 

Definition at line 287 of file Body.h.

References mPosition, and position().

Referenced by gator::CollisionResponseOperator::exec().

void ani::Body::setVelocity const gmtl::Vec3f &    velocity [inline]
 

Definition at line 288 of file Body.h.

References mLinearMomentum, and mMass.

void ani::Body::setRotation const gmtl::Quatf &    rot [inline]
 

Definition at line 289 of file Body.h.

References mRotation.

void ani::Body::setAngularVelocity gmtl::Vec3f &    angularVel [inline]
 

set angular momentum with the given angular velocity calculate L(t), if w(t) is known...

Precondition:
mass and vol should be set first.

Definition at line 295 of file Body.h.

References mAngularMomentum, mBodySpaceInertiaTensor, and mParticle.

Referenced by gator::DriveNavigationOperator::exec().

void ani::Body::applyForce const gmtl::Vec3f &    force [inline]
 

Apply a force to the particle Each call to applyForce adds a force vector and torque to the particle.

call update() to finally apply the accumulated forces which were added with this function. NOTE: the force applied should be with respect to 1.0 unit of time.

Definition at line 308 of file Body.h.

References mForceAccumulator.

Referenced by applyForce(), gator::TireForceOperator::exec(), gator::DriveNavigationOperator::exec(), gator::CollisionResponseOperator::exec(), and gator::Acceleration::exec().

void ani::Body::applyForce const gmtl::Vec3f &    force,
const gmtl::Vec3f &    location,
const gmtl::Vec3f &    center = gmtl::Vec3f( 0.0f, 0.0f, 0.0f )
[inline]
 

apply a force to a position on the body.

this results in a rotation (torque)

Definition at line 316 of file Body.h.

References applyForce(), mParticle, and mTorqueAccumulator.

void ani::Body::applyTorque const gmtl::Vec3f &    torque [inline]
 

Apply a torque to the particle torque is the axis of spin |torque| is the magnitude (i.e.

don't normalize this vec!)

Definition at line 331 of file Body.h.

References mParticle, and mTorqueAccumulator.

virtual void ani::Body::zeroForce   [inline, virtual]
 

Definition at line 339 of file Body.h.

References mForceAccumulator, and mTorqueAccumulator.

void ani::Body::setMass const float &    kilograms [inline]
 

set the mass units are metric kilograms.

Definition at line 348 of file Body.h.

References mInvMass, mMass, and mParticle.

void ani::Body::setVolume gmtl::Vec3f    vol [inline]
 

Definition at line 359 of file Body.h.

References mParticle, and mVolume.

const gmtl::Point3f& ani::Body::position   const [inline]
 

"phase space" (see note above).

Definition at line 373 of file Body.h.

References mPosition.

Referenced by gator::PlaneCollisionDetector::exec(), gator::CollisionResponseOperator::exec(), ani::getWorldBox(), ani::matrix(), and setPosition().

const gmtl::Quatf& ani::Body::rotation   const [inline]
 

Definition at line 374 of file Body.h.

References mRotation.

Referenced by gator::TireForceOperator::exec(), gator::DriveNavigationOperator::exec(), ani::getLocalBox(), and ani::matrix().

gmtl::Vec3f ani::Body::linearVelocity   const [inline]
 

Calculate v(t).

Definition at line 377 of file Body.h.

References mInvMass, and mLinearMomentum.

Referenced by computeDerivative(), gator::TireForceOperator::exec(), gator::PlaneCollisionDetector::exec(), gator::DriveNavigationOperator::exec(), and gator::CollisionResponseOperator::exec().

gmtl::Vec3f ani::Body::angularVelocity const gmtl::Matrix44f &    ws_tensor_inv const [inline]
 

Calculate w(t) using given inertia tensor w(t) = I^-1(t) L(t).

Definition at line 386 of file Body.h.

References mAngularMomentum, and mParticle.

Referenced by computeDerivative().

gmtl::Vec3f ani::Body::angularVelocity   const [inline]
 

Calculate w(t), calcs the inertia tensor for you.

w(t) = I^-1(t) L(t)

Definition at line 397 of file Body.h.

References mParticle.

gmtl::Vec3f ani::Body::linearMomentum   const [inline]
 

Definition at line 405 of file Body.h.

References mLinearMomentum.

gmtl::Vec3f ani::Body::angularMomentum   const [inline]
 

Definition at line 410 of file Body.h.

References mAngularMomentum.

const gmtl::Vec3f& ani::Body::accumulatedForce   const [inline]
 

other things needed by ODE to compute changes in the "phase space".

Definition at line 416 of file Body.h.

References mForceAccumulator.

const gmtl::Vec3f& ani::Body::accumulatedTorque   const [inline]
 

Definition at line 417 of file Body.h.

References mTorqueAccumulator.

const float& ani::Body::mass   const [inline]
 

Definition at line 418 of file Body.h.

References mMass.

Referenced by gator::TireForceOperator::exec(), gator::DriveNavigationOperator::exec(), gator::CollisionResponseOperator::exec(), and gator::Acceleration::exec().

const gmtl::Vec3f& ani::Body::volume   const [inline]
 

Definition at line 419 of file Body.h.

References mVolume.

Referenced by gator::PlaneCollisionDetector::exec(), and ani::getLocalBox().


Member Data Documentation

gmtl::Point3f ani::Body::mPosition
 

Definition at line 424 of file Body.h.

Referenced by addPhase(), Body(), computeDerivative(), copy(), multiplyPhase(), position(), and setPosition().

gmtl::Quatf ani::Body::mRotation
 

Definition at line 425 of file Body.h.

Referenced by addPhase(), Body(), computeDerivative(), copy(), multiplyPhase(), normalize(), rotation(), and setRotation().

gmtl::Vec3f ani::Body::mLinearMomentum
 

Definition at line 426 of file Body.h.

Referenced by addPhase(), Body(), computeDerivative(), copy(), linearMomentum(), linearVelocity(), multiplyPhase(), and setVelocity().

gmtl::Vec3f ani::Body::mAngularMomentum
 

Definition at line 428 of file Body.h.

Referenced by addPhase(), angularMomentum(), angularVelocity(), Body(), computeDerivative(), copy(), multiplyPhase(), and setAngularVelocity().

gmtl::Vec3f ani::Body::mForceAccumulator
 

Definition at line 447 of file Body.h.

Referenced by accumulatedForce(), applyForce(), Body(), computeDerivative(), copy(), and zeroForce().

gmtl::Vec3f ani::Body::mTorqueAccumulator
 

Definition at line 448 of file Body.h.

Referenced by accumulatedTorque(), applyForce(), applyTorque(), Body(), computeDerivative(), copy(), and zeroForce().

float ani::Body::mMass
 

Definition at line 451 of file Body.h.

Referenced by Body(), copy(), mass(), setMass(), and setVelocity().

float ani::Body::mInvMass
 

Definition at line 451 of file Body.h.

Referenced by Body(), copy(), linearVelocity(), and setMass().

gmtl::Vec3f ani::Body::mVolume
 

Definition at line 452 of file Body.h.

Referenced by Body(), copy(), setVolume(), and volume().

gmtl::Matrix44f ani::Body::mBodySpaceInertiaTensor
 

Definition at line 460 of file Body.h.

Referenced by Body(), copy(), and setAngularVelocity().

gmtl::Matrix44f ani::Body::mBodySpaceInertiaTensorInv
 

Definition at line 460 of file Body.h.

Referenced by Body(), and copy().

float ani::Body::mDragCoef
 

Definition at line 463 of file Body.h.

bool ani::Body::mParticle
 

Definition at line 464 of file Body.h.

Referenced by addPhase(), angularVelocity(), applyForce(), applyTorque(), Body(), computeDerivative(), copy(), multiplyPhase(), normalize(), setAngularVelocity(), setMass(), setParticle(), and setVolume().


The documentation for this class was generated from the following file:
Generated on Wed Jun 12 01:54:05 2002 for Animaniac by doxygen1.2.15