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