00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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