mass.h

00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.       *
00004  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
00005  *                                                                       *
00006  * This library is free software; you can redistribute it and/or         *
00007  * modify it under the terms of EITHER:                                  *
00008  *   (1) The GNU Lesser General Public License as published by the Free  *
00009  *       Software Foundation; either version 2.1 of the License, or (at  *
00010  *       your option) any later version. The text of the GNU Lesser      *
00011  *       General Public License is included with this library in the     *
00012  *       file LICENSE.TXT.                                               *
00013  *   (2) The BSD-style license that is included with this library in     *
00014  *       the file LICENSE-BSD.TXT.                                       *
00015  *                                                                       *
00016  * This library is distributed in the hope that it will be useful,       *
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00019  * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
00020  *                                                                       *
00021  *************************************************************************/
00022 
00023 #ifndef _ODE_MASS_H_
00024 #define _ODE_MASS_H_
00025 
00026 #include <ode/common.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 struct dMass;
00033 typedef struct dMass dMass;
00034 
00043 ODE_API int dMassCheck(const dMass *m);
00044 
00045 ODE_API void dMassSetZero (dMass *);
00046 
00047 ODE_API void dMassSetParameters (dMass *, dReal themass,
00048           dReal cgx, dReal cgy, dReal cgz,
00049           dReal I11, dReal I22, dReal I33,
00050           dReal I12, dReal I13, dReal I23);
00051 
00052 ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
00053 ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
00054 
00055 ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
00056          dReal radius, dReal length);
00057 ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
00058          dReal radius, dReal length);
00059 
00060 ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
00061              dReal radius, dReal length);
00062 ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
00063              dReal radius, dReal length);
00064 
00065 ODE_API void dMassSetBox (dMass *, dReal density,
00066         dReal lx, dReal ly, dReal lz);
00067 ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass,
00068              dReal lx, dReal ly, dReal lz);
00069 
00070 ODE_API void dMassAdjust (dMass *, dReal newmass);
00071 
00072 ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
00073 
00074 ODE_API void dMassRotate (dMass *, const dMatrix3 R);
00075 
00076 ODE_API void dMassAdd (dMass *a, const dMass *b);
00077 
00078 // Backwards compatible API
00079 #define dMassSetCappedCylinder dMassSetCapsule
00080 #define dMassSetCappedCylinderTotal dMassSetCapsuleTotal
00081 
00082 
00083 struct dMass {
00084   dReal mass;
00085   dVector4 c;
00086   dMatrix3 I;
00087 
00088 #ifdef __cplusplus
00089   dMass()
00090     { dMassSetZero (this); }
00091   void setZero()
00092     { dMassSetZero (this); }
00093   void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
00094             dReal I11, dReal I22, dReal I33,
00095             dReal I12, dReal I13, dReal I23)
00096     { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
00097   void setSphere (dReal density, dReal radius)
00098     { dMassSetSphere (this,density,radius); }
00099   void setCapsule (dReal density, int direction, dReal a, dReal b)
00100     { dMassSetCappedCylinder (this,density,direction,a,b); }
00101   void setCappedCylinder (dReal density, int direction, dReal a, dReal b)
00102     { setCapsule(density, direction, a, b); }
00103   void setBox (dReal density, dReal lx, dReal ly, dReal lz)
00104     { dMassSetBox (this,density,lx,ly,lz); }
00105   void adjust (dReal newmass)
00106     { dMassAdjust (this,newmass); }
00107   void translate (dReal x, dReal y, dReal z)
00108     { dMassTranslate (this,x,y,z); }
00109   void rotate (const dMatrix3 R)
00110     { dMassRotate (this,R); }
00111   void add (const dMass *b)
00112     { dMassAdd (this,b); }
00113 #endif
00114 };
00115 
00116 
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 
00121 #endif

Generated on Fri Sep 8 21:34:08 2006 for Open Dynamics Engine by  doxygen 1.4.6