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