MathEngine
Home Page       Structures       File List       Functions and Macros      

MdtBody.h File Reference

MdtBody API functions. More...

#include "MePrecision.h"
#include "MdtTypes.h"

Functions

MdtBodyID MdtBodyCreate (const MdtWorldID w)
 Creates a new body with default parameters. More...

void MdtBodyReset (const MdtBodyID b)
 Initialises a body and sets default values. More...

void MdtBodyDestroy (const MdtBodyID b)
 Destroys a body. More...

MdtBodyID MdtBodyCopy (const MdtBodyID b, const MdtWorldID w)
 Puts a copy of an MdtBody into the supplied MdtWorld. More...

void MdtBodyEnable (const MdtBodyID b)
 Enables simulation of this body. More...

void MdtBodyDisable (const MdtBodyID b)
 Removes a body from simulation. More...

void MdtBodyDisableWithConstraints (const MdtBodyID b)
 Removes a body and any constraint affecting it from simulation. More...

int MdtBodyIsEnabled (const MdtBodyID b)
 Indicates whether a body has been removed from simulation, and is not being processed by the solver. More...

void MdtBodyLog (const MdtBodyID b)
 Debug function - output body using MeMessage. More...

MdtBodyID MdtBodyGetFirst (const MdtWorldID w)
 Get the 'first' body in a world. More...

MdtBodyID MdtBodyGetNext (const MdtBodyID b)
 Get the body following the given one in the world. More...

MdtWorldID MdtBodyGetWorld (const MdtBodyID b)
 Returns the WorldID of the world this body is part of. More...

MeReal* MdtBodyGetTransformPtr (const MdtBodyID b)
 Returns a pointer to a bodies 4x4 transformation matrix. More...

void MdtBodyGetTransform (const MdtBodyID b,MeMatrix4 m)
 Returns a copy of a bodies 4x4 transformation matrix. More...

void* MdtBodyGetUserData (const MdtBodyID b)
 Returns the body's UserData pointer. More...

void MdtBodyGetName (const MdtBodyID b, char name[])
 Returns the body's name. More...

MeReal MdtBodyGetMass (const MdtBodyID b)
 Returns the body's mass. More...

void MdtBodyGetInertiaTensor (const MdtBodyID b, MeMatrix3 i)
 The body's 3X3 inertia tensor is returned in i. More...

void MdtBodyGetPosition (const MdtBodyID b, MeVector3 p)
 The body's position vector is returned in p. More...

void MdtBodyGetQuaternion (const MdtBodyID b, MeVector4 q)
 The body's quaternion vector is returned in q. More...

void MdtBodyGetOrientation (const MdtBodyID b, MeMatrix3 v)
 The body's 3X3 rotation matrix is returned in v. More...

void MdtBodyGetLinearVelocity (const MdtBodyID b, MeVector3 v)
 The body's linear velocity vector is returned in v. More...

void MdtBodyGetAngularVelocity (const MdtBodyID b, MeVector3 v)
 The body's angular velocity vector is returned in v. More...

void MdtBodyGetVelocityAtPoint (const MdtBodyID body, MeVector3 p, MeVector3 v)
 Calculate the linear velocity of a point at a position 'p' in the body's reference frame. More...

void MdtBodyGetLinearAcceleration (const MdtBodyID b, MeVector3 v)
 Return's the body's linear acceleration vector in v. More...

void MdtBodyGetAngularAcceleration (const MdtBodyID b, MeVector3 v)
 Return's the body's angular acceleration vector in v. More...

void MdtBodyGetFastSpinAxis (const MdtBodyID b, MeVector3 v)
 Return's the body's fast spin axis in v. More...

MeReal MdtBodyGetLinearVelocityDamping (const MdtBodyID b)
 Returns the linear velocity damping of a body. More...

MeReal MdtBodyGetAngularVelocityDamping (const MdtBodyID b)
 Returns the angular velocity damping of a body. More...

void MdtBodyGetForce (const MdtBodyID b, MeVector3 v)
 Return's the force accumulated on the body so far. More...

void MdtBodyGetTorque (const MdtBodyID b, MeVector3 v)
 Return's the force accumulated on the body so far. More...

MeReal MdtBodyGetKineticEnergy (const MdtBodyID b)
 Return's the body's kinetic energy. More...

void MdtBodySetUserData (const MdtBodyID b, void *d)
 Sets the body's UserData pointer. More...

void MdtBodySetName (const MdtBodyID b, const char name[])
 Sets the body's name. More...

void MdtBodySetTransform (const MdtBodyID b, const MeMatrix4 tm)
 Set's the body's 4X4 transformation matrix. More...

void MdtBodySetMass (const MdtBodyID b, const MeReal mass)
 Sets the mass of a body. More...

void MdtBodySetInertiaTensor (const MdtBodyID b, const MeMatrix3 i)
 Sets the 3X3 inertia tensor of a body. More...

void MdtBodySetPosition (const MdtBodyID b, const MeReal x, const MeReal y, const MeReal z)
 Sets the position of an objects center of mass. More...

void MdtBodySetOrientation (const MdtBodyID b, const MeMatrix3 i)
 Sets the orientation of an object using 3X3 rotation matrix. More...

void MdtBodySetQuaternion (const MdtBodyID b, const MeReal q1, const MeReal q2, const MeReal q3, const MeReal q4)
 Sets the orientation of an object using a quaternion vector. More...

void MdtBodySetLinearVelocity (const MdtBodyID b, const MeReal dx, const MeReal dy, const MeReal dz)
 Sets the linear velocity of a body. More...

void MdtBodySetAngularVelocity (const MdtBodyID b, const MeReal wx, const MeReal wy, const MeReal wz)
 Sets the angular velocity of a body. More...

void MdtBodySetLinearVelocityDamping (const MdtBodyID b, const MeReal d)
 Sets the velocity damping of a body. More...

void MdtBodySetAngularVelocityDamping (const MdtBodyID b, const MeReal d)
 Sets the angular velocity damping of a body. More...

void MdtBodySetFastSpinAxis (const MdtBodyID b, const MeReal x, const MeReal y, const MeReal z)
 Sets the fast spin axis of rotation of a body. More...

void MdtBodySetNoFastSpinAxis (const MdtBodyID b)
 Disables fast spin for a body. More...

void MdtBodyResetForces (const MdtBodyID b)
 Reset forces and torques being applied to body to zero. More...

void MdtBodyAddForce (const MdtBodyID b, const MeReal fx, const MeReal fy, const MeReal fz)
 Add a force vector to a body. More...

void MdtBodyAddForceAtPosition (const MdtBodyID b, const MeReal fx, const MeReal fy, const MeReal fz, const MeReal px, const MeReal py, const MeReal pz)
 Apply a force at a specific point on a body. More...

void MdtBodyAddTorque (const MdtBodyID b, const MeReal tx, const MeReal ty, const MeReal tz)
 Add a torque to a body. More...

void MdtBodyAddImpulse (const MdtBodyID b, const MeReal ix, const MeReal iy, const MeReal iz)
 Add an instanteous impulse vector to a body. More...

void MdtBodyAddImpulseAtPosition (const MdtBodyID b, const MeReal ix, const MeReal iy, const MeReal iz, const MeReal px, const MeReal py, const MeReal pz)
 Apply an instantaneous impulse at a specific point on a body. More...


Detailed Description

MdtBody API functions.


Function Documentation

void MdtBodyAddForce ( MdtBodyID b,
MeReal fx,
MeReal fy,
MeReal fz )

Add a force vector to a body.

The force is applied at the centre of mass and is set in the world reference frame. Forces are accumulated on a body until the body is next simulated, when they are used.

void MdtBodyAddForceAtPosition ( MdtBodyID b,
MeReal fx,
MeReal fy,
MeReal fz,
MeReal px,
MeReal py,
MeReal pz )

Apply a force at a specific point on a body.

Parameters:
b   Body to apply force to.
f   [xyz] Force to be applied in world reference frame.
p   [xyz] Position to apply force to in world reference frame.

void MdtBodyAddImpulse ( MdtBodyID b,
MeReal ix,
MeReal iy,
MeReal iz )

Add an instanteous impulse vector to a body.

void MdtBodyAddImpulseAtPosition ( MdtBodyID b,
MeReal ix,
MeReal iy,
MeReal iz,
MeReal px,
MeReal py,
MeReal pz )

Apply an instantaneous impulse at a specific point on a body.

Parameters:
b   Body to apply force to.
i   [xyz] Impulse to be applied in world reference frame.
p   [xyz] Position to apply impulse to in world reference frame.

void MdtBodyAddTorque ( MdtBodyID b,
MeReal tx,
MeReal ty,
MeReal tz )

Add a torque to a body.

The torque vector is set in the world reference frame.

MdtBodyID MdtBodyCopy ( MdtBodyID b,
MdtWorldID w )

Puts a copy of an MdtBody into the supplied MdtWorld.

MdtBodyID MdtBodyCreate ( MdtWorldID w )

Creates a new body with default parameters.

See also:
MdtBodyReset()

void MdtBodyDestroy ( MdtBodyID b )

Destroys a body.

void MdtBodyDisable ( MdtBodyID b )

Removes a body from simulation.

A 'disabled' body will not be simulated. You can use the MdtDEMModePartitionAutoDisable option with MdtWorldSetDEMMode to automatically disable bodies when they come to rest. If the partitioner is enabled, bodies will be automatically enabled when hit by an enabled body etc.

See also:
MdtBodyEnable() , MdtBodyDisableWithConstraints() , MdtDEMMode

void MdtBodyDisableWithConstraints ( MdtBodyID b )

Removes a body and any constraint affecting it from simulation.

This function will not only remove a body from simulation, but will remove any constraints that affect it from simulation as well. This can be useful when, for example, disabling a link in the middle of a chain.

See also:
MdtBodyEnable() , MdtBodyDisable()

void MdtBodyEnable ( MdtBodyID b )

Enables simulation of this body.

By default, bodies are disabled from simulation. This function enables simulation of that body. Bodies are automatically enabled when hit by other enabled bodies, for example.

See also:
MdtBodyDisable()

void MdtBodyGetAngularAcceleration ( MdtBodyID b,
MeVector3 v )

Return's the body's angular acceleration vector in v.

Acceleration is READ ONLY, and is given in the world reference frame.

void MdtBodyGetAngularVelocity ( MdtBodyID b,
MeVector3 v )

The body's angular velocity vector is returned in v.

The angular velocity is given as as an (x, y, z) vector.

MeReal MdtBodyGetAngularVelocityDamping ( MdtBodyID b )

Returns the angular velocity damping of a body.

Damping is a torque (newton-meters/radian/sec) opposing the body's angular velocity. 0 indicates no damping.

void MdtBodyGetFastSpinAxis ( MdtBodyID b,
MeVector3 v )

Return's the body's fast spin axis in v.

MdtBodyID MdtBodyGetFirst ( MdtWorldID w )

Get the 'first' body in a world.

void MdtBodyGetForce ( MdtBodyID b,
MeVector3 v )

Return's the force accumulated on the body so far.

void MdtBodyGetInertiaTensor ( MdtBodyID b,
MeMatrix3 i )

The body's 3X3 inertia tensor is returned in i.

The inertia tensor of a body is given in the bodies reference frame.

MeReal MdtBodyGetKineticEnergy ( MdtBodyID b )

Return's the body's kinetic energy.

void MdtBodyGetLinearAcceleration ( MdtBodyID b,
MeVector3 v )

Return's the body's linear acceleration vector in v.

Acceleration is READ ONLY, and is given in the world reference frame.

void MdtBodyGetLinearVelocity ( MdtBodyID b,
MeVector3 v )

The body's linear velocity vector is returned in v.

The velocity is given in the world reference frame.

MeReal MdtBodyGetLinearVelocityDamping ( MdtBodyID b )

Returns the linear velocity damping of a body.

Damping is a force (newtons/unit/sec) opposing the body's velocity. 0 indicates no damping.

MeReal MdtBodyGetMass ( MdtBodyID b )

Returns the body's mass.

void MdtBodyGetName ( MdtBodyID b,
char name[] )

Returns the body's name.

Naming a body is very useful in conjunction with the logging functions.

MdtBodyID MdtBodyGetNext ( MdtBodyID b )

Get the body following the given one in the world.

void MdtBodyGetOrientation ( MdtBodyID b,
MeMatrix3 v )

The body's 3X3 rotation matrix is returned in v.

The rotation matrix is relative to the world reference frame.

void MdtBodyGetPosition ( MdtBodyID b,
MeVector3 p )

The body's position vector is returned in p.

The position is of the bodies center of mass, and is given in the world reference frame.

void MdtBodyGetQuaternion ( MdtBodyID b,
MeVector4 q )

The body's quaternion vector is returned in q.

The quaternion is in the form (w, x, y, z), and is relative to the world reference frame.

void MdtBodyGetTorque ( MdtBodyID b,
MeVector3 v )

Return's the force accumulated on the body so far.

void MdtBodyGetTransform ( MdtBodyID b,
MeMatrix4 m )

Returns a copy of a bodies 4x4 transformation matrix.

MeReal * MdtBodyGetTransformPtr ( MdtBodyID b )

Returns a pointer to a bodies 4x4 transformation matrix.

The lifetime of this transformation is not guaranteed.

void * MdtBodyGetUserData ( MdtBodyID b )

Returns the body's UserData pointer.

void MdtBodyGetVelocityAtPoint ( MdtBodyID body,
MeVector3 p,
MeVector3 v )

Calculate the linear velocity of a point at a position 'p' in the body's reference frame.

MdtWorldID MdtBodyGetWorld ( MdtBodyID b )

Returns the WorldID of the world this body is part of.

int MdtBodyIsEnabled ( MdtBodyID b )

Indicates whether a body has been removed from simulation, and is not being processed by the solver.

0 if disabled, 1 if enabled.

See also:
MdtWorldSetDEMMode()

void MdtBodyLog ( MdtBodyID b )

Debug function - output body using MeMessage.

void MdtBodyReset ( MdtBodyID b )

Initialises a body and sets default values.

Default values (gives a sphere of radius 1, mass 1):

See also:
struct MdtBody

void MdtBodyResetForces ( MdtBodyID b )

Reset forces and torques being applied to body to zero.

See also:
MdtBodyAddForce() , MdtBodyAddTorque()

void MdtBodySetAngularVelocity ( MdtBodyID b,
MeReal wx,
MeReal wy,
MeReal wz )

Sets the angular velocity of a body.

Angular velocity is set in the world reference frame.

void MdtBodySetAngularVelocityDamping ( MdtBodyID b,
MeReal d )

Sets the angular velocity damping of a body.

Angular velocity damping applies a torque (newton-meters/radian/sec) opposing the body's angular velocity. 0 indicates no damping.

Warning:
A body can lose stability if the damping is too large.

void MdtBodySetFastSpinAxis ( MdtBodyID b,
MeReal x,
MeReal y,
MeReal z )

Sets the fast spin axis of rotation of a body.

Fast spin is used for spinning objects like wheels.

void MdtBodySetInertiaTensor ( MdtBodyID b,
MeMatrix3 i )

Sets the 3X3 inertia tensor of a body.

The inertia tensor must be diagonally symmetrical and greater than zero.

Warning:
A body can lose stability if the inertia tensor is too small.

void MdtBodySetLinearVelocity ( MdtBodyID b,
MeReal dx,
MeReal dy,
MeReal dz )

Sets the linear velocity of a body.

Linear velocity is set in the world reference frame.

void MdtBodySetLinearVelocityDamping ( MdtBodyID b,
MeReal d )

Sets the velocity damping of a body.

Damping applies a force (newtons/unit/sec) opposing the body's velocity. 0 indicates no damping.

Warning:
A body can lose stability if the damping is too large.

void MdtBodySetMass ( MdtBodyID b,
MeReal mass )

Sets the mass of a body.

void MdtBodySetName ( MdtBodyID b,
char name[] )

Sets the body's name.

void MdtBodySetNoFastSpinAxis ( MdtBodyID b )

Disables fast spin for a body.

void MdtBodySetOrientation ( MdtBodyID b,
MeMatrix3 i )

Sets the orientation of an object using 3X3 rotation matrix.

void MdtBodySetPosition ( MdtBodyID b,
MeReal x,
MeReal y,
MeReal z )

Sets the position of an objects center of mass.

The position of an object is set in the world reference frame.

void MdtBodySetQuaternion ( MdtBodyID b,
MeReal q1,
MeReal q2,
MeReal q3,
MeReal q4 )

Sets the orientation of an object using a quaternion vector.

The quaternion is in the form (w, x, y, z).

void MdtBodySetTransform ( MdtBodyID b,
MeMatrix4 tm )

Set's the body's 4X4 transformation matrix.

void MdtBodySetUserData ( MdtBodyID b,
void * d )

Sets the body's UserData pointer.


MathEngine Dynamics Toolkit - Version 0.0.5 Alpha - Reference Manual generated using doxygen at Wed Oct 11 00:34:46 2000

Copyright MathEngine PLC 2000, all rights reserved.