Panda3D
Loading...
Searching...
No Matches
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
14INLINE int OdeMass::
15check() {
16 return dMassCheck(&_mass);
17}
18
19INLINE void OdeMass::
20set_zero() {
21 _mass.setZero();
22}
23
24INLINE void OdeMass::
25set_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
35INLINE void OdeMass::
36set_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
45INLINE void OdeMass::
46set_sphere(dReal density, dReal radius) {
47 _mass.setSphere(density, radius);
48}
49
50INLINE void OdeMass::
51set_sphere_total(dReal total_mass, dReal radius) {
52 dMassSetSphereTotal(&_mass, total_mass, radius);
53}
54
55INLINE void OdeMass::
56set_capsule(dReal density, int direction,
57 dReal radius, dReal length) {
58 _mass.setCapsule(density, direction,
59 radius, length);
60}
61
62INLINE void OdeMass::
63set_capsule_total(dReal total_mass, int direction,
64 dReal radius, dReal length) {
65 dMassSetCapsuleTotal(&_mass,
66 total_mass, direction,
67 radius, length);
68}
69
70INLINE void OdeMass::
71set_cylinder(dReal density, int direction,
72 dReal radius, dReal length) {
73 dMassSetCylinder(&_mass,
74 density,direction,
75 radius,length);
76}
77
78INLINE void OdeMass::
79set_cylinder_total(dReal total_mass, int direction,
80 dReal radius, dReal length) {
81 dMassSetCylinderTotal(&_mass, total_mass, direction,
82 radius, length);
83}
84
85INLINE void OdeMass::
86set_box(dReal density,
87 dReal lx, dReal ly, dReal lz) {
88 _mass.setBox(density,
89 lx, ly, lz);
90}
91
92INLINE void OdeMass::
93set_box(dReal density,
94 const LVecBase3f &size) {
95 _mass.setBox(density,
96 size[0], size[1], size[2]);
97}
98
99INLINE void OdeMass::
100set_box_total(dReal total_mass,
101 const LVecBase3f &size) {
102 dMassSetBoxTotal(&_mass,
103 total_mass,
104 size[0], size[1], size[2]);
105}
106
107INLINE void OdeMass::
108set_box_total(dReal total_mass,
109 dReal lx, dReal ly, dReal lz) {
110 dMassSetBoxTotal(&_mass,
111 total_mass,
112 lx, ly, lz);
113}
114
115INLINE void OdeMass::
116adjust(dReal newmass) {
117 _mass.adjust(newmass);
118}
119
120INLINE void OdeMass::
121translate(dReal x, dReal y, dReal z) {
122 _mass.translate(x, y, z);
123}
124
125INLINE void OdeMass::
126translate(const LVecBase3f &pos) {
127 translate(pos[0], pos[1], pos[2]);
128}
129
130INLINE void OdeMass::
131rotate(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
138INLINE void OdeMass::
139add(OdeMass &other) {
140 _mass.add(other.get_mass_ptr());
141}
142
143INLINE dReal OdeMass::
144get_magnitude() const {
145 return _mass.mass;
146}
147
148INLINE LPoint3f OdeMass::
149get_center() const {
150 return LPoint3f(_mass.c[0], _mass.c[1], _mass.c[2]);
151}
152
153INLINE LMatrix3f OdeMass::
154get_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}