Panda3D
odeMass.I
1 // Filename: odeMass.I
2 // Created by: joswilso (27Dec06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 INLINE int OdeMass::
16 check() {
17  return dMassCheck(&_mass);
18 }
19 
20 INLINE void OdeMass::
21 set_zero() {
22  _mass.setZero();
23 }
24 
25 INLINE void OdeMass::
26 set_parameters(dReal themass,
27  dReal cgx, dReal cgy, dReal cgz,
28  dReal I11, dReal I22, dReal I33,
29  dReal I12, dReal I13, dReal I23) {
30  _mass.setParameters(themass,
31  cgx, cgy, cgz,
32  I11, I22, I33,
33  I12, I13, I23);
34 }
35 
36 INLINE void OdeMass::
37 set_parameters(dReal themass,
38  const LVecBase3f &center,
39  const LMatrix3f &i) {
40  set_parameters(themass,
41  center[0], center[1], center[2],
42  i(0, 0), i(1, 1), i(2, 2),
43  i(0, 1), i(0, 2), i(1, 2));
44 }
45 
46 INLINE void OdeMass::
47 set_sphere(dReal density, dReal radius) {
48  _mass.setSphere(density, radius);
49 }
50 
51 INLINE void OdeMass::
52 set_sphere_total(dReal total_mass, dReal radius) {
53  dMassSetSphereTotal(&_mass, total_mass, radius);
54 }
55 
56 INLINE void OdeMass::
57 set_capsule(dReal density, int direction,
58  dReal radius, dReal length) {
59  _mass.setCapsule(density, direction,
60  radius, length);
61 }
62 
63 INLINE void OdeMass::
64 set_capsule_total(dReal total_mass, int direction,
65  dReal radius, dReal length) {
66  dMassSetCapsuleTotal(&_mass,
67  total_mass, direction,
68  radius, length);
69 }
70 
71 INLINE void OdeMass::
72 set_cylinder(dReal density, int direction,
73  dReal radius, dReal length) {
74  dMassSetCylinder(&_mass,
75  density,direction,
76  radius,length);
77 }
78 
79 INLINE void OdeMass::
80 set_cylinder_total(dReal total_mass, int direction,
81  dReal radius, dReal length) {
82  dMassSetCylinderTotal(&_mass, total_mass, direction,
83  radius, length);
84 }
85 
86 INLINE void OdeMass::
87 set_box(dReal density,
88  dReal lx, dReal ly, dReal lz) {
89  _mass.setBox(density,
90  lx, ly, lz);
91 }
92 
93 INLINE void OdeMass::
94 set_box(dReal density,
95  const LVecBase3f &size) {
96  _mass.setBox(density,
97  size[0], size[1], size[2]);
98 }
99 
100 INLINE void OdeMass::
101 set_box_total(dReal total_mass,
102  const LVecBase3f &size) {
103  dMassSetBoxTotal(&_mass,
104  total_mass,
105  size[0], size[1], size[2]);
106 }
107 
108 INLINE void OdeMass::
109 set_box_total(dReal total_mass,
110  dReal lx, dReal ly, dReal lz) {
111  dMassSetBoxTotal(&_mass,
112  total_mass,
113  lx, ly, lz);
114 }
115 
116 INLINE void OdeMass::
117 adjust(dReal newmass) {
118  _mass.adjust(newmass);
119 }
120 
121 INLINE void OdeMass::
122 translate(dReal x, dReal y, dReal z) {
123  _mass.translate(x, y, z);
124 }
125 
126 INLINE void OdeMass::
127 translate(const LVecBase3f &pos) {
128  translate(pos[0], pos[1], pos[2]);
129 }
130 
131 INLINE void OdeMass::
132 rotate(const LMatrix3f &r) {
133  dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
134  r(1, 0), r(1, 1), r(1, 2), 0,
135  r(2, 0), r(2, 1), r(2, 2), 0 };
136  _mass.rotate(rot);
137 }
138 
139 INLINE void OdeMass::
140 add(OdeMass &other) {
141  _mass.add(other.get_mass_ptr());
142 }
143 
144 INLINE dReal OdeMass::
145 get_magnitude() const {
146  return _mass.mass;
147 }
148 
149 INLINE LPoint3f OdeMass::
150 get_center() const {
151  return LPoint3f(_mass.c[0], _mass.c[1], _mass.c[2]);
152 }
153 
154 INLINE LMatrix3f OdeMass::
155 get_inertial_tensor() const {
156  return LMatrix3f(_mass.I[0], _mass.I[1], _mass.I[2] ,
157  _mass.I[4], _mass.I[5], _mass.I[6] ,
158  _mass.I[8], _mass.I[9], _mass.I[10]);
159 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110