ODE  0.13.1
 All Data Structures Functions Variables Typedefs Enumerations Groups
mass.h
1 /*************************************************************************
2  * *
3  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4  * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of EITHER: *
8  * (1) The GNU Lesser General Public License as published by the Free *
9  * Software Foundation; either version 2.1 of the License, or (at *
10  * your option) any later version. The text of the GNU Lesser *
11  * General Public License is included with this library in the *
12  * file LICENSE.TXT. *
13  * (2) The BSD-style license that is included with this library in *
14  * the file LICENSE-BSD.TXT. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19  * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20  * *
21  *************************************************************************/
22 
23 #ifndef _ODE_MASS_H_
24 #define _ODE_MASS_H_
25 
26 #include <ode/common.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 struct dMass;
33 typedef struct dMass dMass;
34 
43 ODE_API int dMassCheck(const dMass *m);
44 
45 ODE_API void dMassSetZero (dMass *);
46 
47 ODE_API void dMassSetParameters (dMass *, dReal themass,
48  dReal cgx, dReal cgy, dReal cgz,
49  dReal I11, dReal I22, dReal I33,
50  dReal I12, dReal I13, dReal I23);
51 
52 ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
53 ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
54 
55 ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
56  dReal radius, dReal length);
57 ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
58  dReal radius, dReal length);
59 
60 ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
61  dReal radius, dReal length);
62 ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
63  dReal radius, dReal length);
64 
65 ODE_API void dMassSetBox (dMass *, dReal density,
66  dReal lx, dReal ly, dReal lz);
67 ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass,
68  dReal lx, dReal ly, dReal lz);
69 
70 ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g);
71 
72 ODE_API void dMassSetTrimeshTotal (dMass *m, dReal total_mass, dGeomID g);
73 
74 ODE_API void dMassAdjust (dMass *, dReal newmass);
75 
76 ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
77 
78 ODE_API void dMassRotate (dMass *, const dMatrix3 R);
79 
80 ODE_API void dMassAdd (dMass *a, const dMass *b);
81 
82 
83 /* Backwards compatible API */
84 ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e);
85 ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e);
86 
87 
88 struct dMass {
89  dReal mass;
90  dVector3 c;
91  dMatrix3 I;
92 
93 #ifdef __cplusplus
94  dMass()
95  { dMassSetZero (this); }
96  void setZero()
97  { dMassSetZero (this); }
98  void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
99  dReal I11, dReal I22, dReal I33,
100  dReal I12, dReal I13, dReal I23)
101  { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
102 
103  void setSphere (dReal density, dReal radius)
104  { dMassSetSphere (this,density,radius); }
105  void setSphereTotal (dReal total, dReal radius)
106  { dMassSetSphereTotal (this,total,radius); }
107 
108  void setCapsule (dReal density, int direction, dReal radius, dReal length)
109  { dMassSetCapsule (this,density,direction,radius,length); }
110  void setCapsuleTotal (dReal total, int direction, dReal radius, dReal length)
111  { dMassSetCapsule (this,total,direction,radius,length); }
112 
113  void setCylinder(dReal density, int direction, dReal radius, dReal length)
114  { dMassSetCylinder (this,density,direction,radius,length); }
115  void setCylinderTotal(dReal total, int direction, dReal radius, dReal length)
116  { dMassSetCylinderTotal (this,total,direction,radius,length); }
117 
118  void setBox (dReal density, dReal lx, dReal ly, dReal lz)
119  { dMassSetBox (this,density,lx,ly,lz); }
120  void setBoxTotal (dReal total, dReal lx, dReal ly, dReal lz)
121  { dMassSetBoxTotal (this,total,lx,ly,lz); }
122 
123  void setTrimesh(dReal density, dGeomID g)
124  { dMassSetTrimesh (this, density, g); }
125  void setTrimeshTotal(dReal total, dGeomID g)
126  { dMassSetTrimeshTotal (this, total, g); }
127 
128  void adjust (dReal newmass)
129  { dMassAdjust (this,newmass); }
130  void translate (dReal x, dReal y, dReal z)
131  { dMassTranslate (this,x,y,z); }
132  void rotate (const dMatrix3 R)
133  { dMassRotate (this,R); }
134  void add (const dMass *b)
135  { dMassAdd (this,b); }
136 #endif
137 };
138 
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
Definition: mass.h:88