deMassProp.h

Go to the documentation of this file.
00001 /* Copyright (c) 2005 Arachi, Inc. and Stanford University.
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining
00004  * a copy of this software and associated documentation files (the
00005  * "Software"), to deal in the Software without restriction, including
00006  * without limitation the rights to use, copy, modify, merge, publish,
00007  * distribute, sublicense, and/or sell copies of the Software, and to
00008  * permit persons to whom the Software is furnished to do so, subject
00009  * to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00018  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00019  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00020  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021  */
00022 
00023 #ifndef _deMassProp_h
00024 #define _deMassProp_h
00025 
00026 #include "deTypes.h"
00027 #include "deMath.h"
00028 
00034 //      @{
00035 #define DE_DENSITY_AIR                          (-1.2062f)
00036 #define DE_DENSITY_ALUMINUM                     (-2690.0f)
00037 #define DE_DENSITY_CONCRETE                     (-2400.0f)
00038 #define DE_DENSITY_COPPER                       (-8910.0f)
00039 #define DE_DENSITY_EARTH_WET            (-1760.0f)
00040 #define DE_DENSITY_EARTH_DRY            (-1280.0f)
00041 #define DE_DENSITY_GLASS                        (-2590.0f)
00042 #define DE_DENSITY_GOLD                         (-19300.0f)
00043 #define DE_DENSITY_ICE                          (-900.0f)
00044 #define DE_DENSITY_IRON                         (-7210.0f)
00045 #define DE_DENSITY_LEAD                         (-11370.0f)
00046 #define DE_DENSITY_MERCURY                      (-13570.0f)
00047 #define DE_DENSITY_OIL                          (-900.0f)
00048 #define DE_DENSITY_STEEL                        (-7830.0f)
00049 #define DE_DENSITY_TITANIUM                     (-3080.0f)
00050 #define DE_DENSITY_WATER                        (-1000.0f)
00051 #define DE_DENSITY_WATER_SALT           (-1030.0f)
00052 #define DE_DENSITY_WOOD_SOFTPINE        (-480.0f)
00053 #define DE_DENSITY_WOOD_HARDOAK         (-800.0f)
00054 //      @}
00055 
00060 class deMassProp
00061 {
00062 public:
00064         deMassProp() { zero(); }
00066         void zero() {
00067                 _m = 0;
00068                 _center.zero();
00069                 _inertia.zero();
00070         }
00072         void set(const deFloat* mass, const deVector3* center, const deMatrix3* inertia)
00073         {
00074                 _m = *mass;
00075                 _center = *center;
00076                 _inertia = *inertia;
00077         }
00079         void get(deFloat* mass, deVector3* center, deMatrix3* inertia)
00080         {
00081                 *mass = _m;
00082                 *center = _center;
00083                 *inertia = _inertia;
00084         }
00091         deInt isDensity(deFloat m) { return (m < 0); }
00092 
00096         deFloat* mass() { return &_m; }
00098         deMatrix3* inertia() { return &_inertia; }
00100         deVector3* center() { return &_center; }
00108         void mass(const deFloat m, const deFrame* f = NULL);
00112         void inertia(const deMatrix3* inertia, const deFrame* f = NULL);
00114         void inertia(const deVector3* diag, const deFrame* f = NULL); 
00116         void inertia(const deFloat Ixx,const deFloat Iyy,const deFloat Izz, const deFrame* f = NULL);
00125         void cylinder(const deFloat mp, const deFloat h, const deFloat r, const deFrame* f = NULL);
00134         void cone(const deFloat mp, const deFloat h, const deFloat r, const deFrame* f = NULL);
00144         void pyramid(const deFloat mp, const deFloat a, const deFloat b, const deFloat h, const deFrame* f = NULL);
00155         void block(const deFloat mp, const deFloat a, const deFloat b, const deFloat c, const deFrame* f = NULL);
00165         void sphere(const deFloat mp, const deFloat r, const deFrame* f = NULL);
00173         void hemisphere(const deFloat mp, const deFloat r, const deFrame* f = NULL);
00182         void ellipsoid(const deFloat mp, const deFloat a, const deFloat b, const deFloat c, const deFrame* f = NULL);
00192         void rod(const deFloat mp, const deFloat l, const deFrame* f = NULL);
00201         void disk(const deFloat mp, const deFloat r, const deFrame* f = NULL);
00210         void plate(const deFloat mp, const deFloat a, const deFloat b, const deFrame* f = NULL);
00220         void cylinderShell(const deFloat mp, const deFloat h, const deFloat r, const deFrame* f = NULL);
00229         void coneShell(const deFloat mp, const deFloat h, const deFloat r, const deFrame* f = NULL);
00239         void sphereShell(const deFloat mp, const deFloat r, const deFrame* f = NULL);
00247         void hemisphereShell(const deFloat mp, const deFloat r, const deFrame* f = NULL);
00261         void scale(const deFloat m); 
00266 
00267 private:
00268         deFloat _m;
00269         deVector3 _center;
00270         deMatrix3 _inertia;
00271 };
00272 #endif

Generated on Sun Apr 9 22:12:42 2006 for TAO by  doxygen 1.4.6-NO