classicui_plat/ode_api/inc/mass.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 
       
    35 /**
       
    36  * Check if a mass structure has valid value.
       
    37  * The function check if the mass and innertia matrix are positive definits
       
    38  *
       
    39  * @param m A mass structure to check
       
    40  *
       
    41  * @return 1 if both codition are met
       
    42  */
       
    43 ODE_API IMPORT_C int dMassCheck(const dMass *m);
       
    44 
       
    45 ODE_API IMPORT_C void dMassSetZero (dMass *);
       
    46 
       
    47 ODE_API IMPORT_C 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 IMPORT_C void dMassSetSphere (dMass *, dReal density, dReal radius);
       
    53 ODE_API IMPORT_C void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
       
    54 
       
    55 ODE_API IMPORT_C void dMassSetCapsule (dMass *, dReal density, int direction,
       
    56 		  	dReal radius, dReal length);
       
    57 ODE_API IMPORT_C void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
       
    58 			dReal radius, dReal length);
       
    59 
       
    60 ODE_API IMPORT_C void dMassSetCylinder (dMass *, dReal density, int direction,
       
    61 		       dReal radius, dReal length);
       
    62 ODE_API IMPORT_C void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
       
    63 			    dReal radius, dReal length);
       
    64 
       
    65 ODE_API IMPORT_C void dMassSetBox (dMass *, dReal density,
       
    66 		  dReal lx, dReal ly, dReal lz);
       
    67 ODE_API IMPORT_C 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 IMPORT_C void dMassAdjust (dMass *, dReal newmass);
       
    73 
       
    74 ODE_API IMPORT_C void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
       
    75 
       
    76 ODE_API IMPORT_C void dMassRotate (dMass *, const dMatrix3 R);
       
    77 
       
    78 ODE_API IMPORT_C void dMassAdd (dMass *a, const dMass *b);
       
    79 
       
    80 // Backwards compatible API
       
    81 #define dMassSetCappedCylinder dMassSetCapsule
       
    82 #define dMassSetCappedCylinderTotal dMassSetCapsuleTotal
       
    83 
       
    84 
       
    85 struct dMass {
       
    86   dReal mass;
       
    87   dVector4 c;
       
    88   dMatrix3 I;
       
    89 
       
    90 #ifdef __cplusplus
       
    91   dMass()
       
    92     { dMassSetZero (this); }
       
    93   void setZero()
       
    94     { dMassSetZero (this); }
       
    95   void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
       
    96 		      dReal I11, dReal I22, dReal I33,
       
    97 		      dReal I12, dReal I13, dReal I23)
       
    98     { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
       
    99   void setSphere (dReal density, dReal radius)
       
   100     { dMassSetSphere (this,density,radius); }
       
   101   void setCapsule (dReal density, int direction, dReal a, dReal b)
       
   102     { dMassSetCappedCylinder (this,density,direction,a,b); }
       
   103   void setCappedCylinder (dReal density, int direction, dReal a, dReal b)
       
   104     { setCapsule(density, direction, a, b); }
       
   105   void setBox (dReal density, dReal lx, dReal ly, dReal lz)
       
   106     { dMassSetBox (this,density,lx,ly,lz); }
       
   107   void adjust (dReal newmass)
       
   108     { dMassAdjust (this,newmass); }
       
   109   void translate (dReal x, dReal y, dReal z)
       
   110     { dMassTranslate (this,x,y,z); }
       
   111   void rotate (const dMatrix3 R)
       
   112     { dMassRotate (this,R); }
       
   113   void add (const dMass *b)
       
   114     { dMassAdd (this,b); }
       
   115 #endif
       
   116 };
       
   117 
       
   118 
       
   119 #ifdef __cplusplus
       
   120 }
       
   121 #endif
       
   122 
       
   123 #endif