mass.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] 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. #ifndef _ODE_MASS_H_
  23. #define _ODE_MASS_H_
  24. #include <ode/common.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. struct dMass;
  29. typedef struct dMass dMass;
  30. /**
  31. * Check if a mass structure has valid value.
  32. * The function check if the mass and innertia matrix are positive definits
  33. *
  34. * @param m A mass structure to check
  35. *
  36. * @return 1 if both codition are met
  37. */
  38. ODE_API int dMassCheck(const dMass *m);
  39. ODE_API void dMassSetZero (dMass *);
  40. ODE_API void dMassSetParameters (dMass *, dReal themass,
  41. dReal cgx, dReal cgy, dReal cgz,
  42. dReal I11, dReal I22, dReal I33,
  43. dReal I12, dReal I13, dReal I23);
  44. ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
  45. ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
  46. ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
  47. dReal radius, dReal length);
  48. ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
  49. dReal radius, dReal length);
  50. ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
  51. dReal radius, dReal length);
  52. ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
  53. dReal radius, dReal length);
  54. ODE_API void dMassSetBox (dMass *, dReal density,
  55. dReal lx, dReal ly, dReal lz);
  56. ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass,
  57. dReal lx, dReal ly, dReal lz);
  58. ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g);
  59. ODE_API void dMassSetTrimeshTotal (dMass *m, dReal total_mass, dGeomID g);
  60. ODE_API void dMassAdjust (dMass *, dReal newmass);
  61. ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
  62. ODE_API void dMassRotate (dMass *, const dMatrix3 R);
  63. ODE_API void dMassAdd (dMass *a, const dMass *b);
  64. /* Backwards compatible API */
  65. ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e);
  66. ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e);
  67. struct dMass {
  68. dReal mass;
  69. dVector3 c;
  70. dMatrix3 I;
  71. #ifdef __cplusplus
  72. dMass()
  73. { dMassSetZero (this); }
  74. void setZero()
  75. { dMassSetZero (this); }
  76. void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
  77. dReal I11, dReal I22, dReal I33,
  78. dReal I12, dReal I13, dReal I23)
  79. { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
  80. void setSphere (dReal density, dReal radius)
  81. { dMassSetSphere (this,density,radius); }
  82. void setSphereTotal (dReal total, dReal radius)
  83. { dMassSetSphereTotal (this,total,radius); }
  84. void setCapsule (dReal density, int direction, dReal radius, dReal length)
  85. { dMassSetCapsule (this,density,direction,radius,length); }
  86. void setCapsuleTotal (dReal total, int direction, dReal radius, dReal length)
  87. { dMassSetCapsule (this,total,direction,radius,length); }
  88. void setCylinder(dReal density, int direction, dReal radius, dReal length)
  89. { dMassSetCylinder (this,density,direction,radius,length); }
  90. void setCylinderTotal(dReal total, int direction, dReal radius, dReal length)
  91. { dMassSetCylinderTotal (this,total,direction,radius,length); }
  92. void setBox (dReal density, dReal lx, dReal ly, dReal lz)
  93. { dMassSetBox (this,density,lx,ly,lz); }
  94. void setBoxTotal (dReal total, dReal lx, dReal ly, dReal lz)
  95. { dMassSetBoxTotal (this,total,lx,ly,lz); }
  96. void setTrimesh(dReal density, dGeomID g)
  97. { dMassSetTrimesh (this, density, g); }
  98. void setTrimeshTotal(dReal total, dGeomID g)
  99. { dMassSetTrimeshTotal (this, total, g); }
  100. void adjust (dReal newmass)
  101. { dMassAdjust (this,newmass); }
  102. void translate (dReal x, dReal y, dReal z)
  103. { dMassTranslate (this,x,y,z); }
  104. void rotate (const dMatrix3 R)
  105. { dMassRotate (this,R); }
  106. void add (const dMass *b)
  107. { dMassAdd (this,b); }
  108. #endif
  109. };
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif