You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// A revolute joint, locks all relative motion except for rotation along the joint’s principal axis.
9
15
pubstructRevoluteJoint{
10
-
data:GenericJoint,
16
+
/// The underlying joint data.
17
+
pubdata:GenericJoint,
11
18
}
12
19
13
20
#[cfg(feature = "dim2")]
@@ -37,11 +44,6 @@ impl RevoluteJoint {
37
44
Self{ data }
38
45
}
39
46
40
-
/// The underlying generic joint.
41
-
pubfndata(&self) -> &GenericJoint{
42
-
&self.data
43
-
}
44
-
45
47
/// Are contacts between the attached rigid-bodies enabled?
46
48
pubfncontacts_enabled(&self) -> bool{
47
49
self.data.contacts_enabled()
@@ -138,6 +140,41 @@ impl RevoluteJoint {
138
140
self.data.set_limits(JointAxis::AngX, limits);
139
141
self
140
142
}
143
+
144
+
/// The angle along the free degree of freedom of this revolute joint in `[-π, π]`.
145
+
///
146
+
/// See also [`Self::angle`] for a version of this method taking entities instead of rigid-body handles.
147
+
/// Similarly [`RapierContext::impulse_revolute_joint_angle`] only takes a single entity as argument to compute that angle.
148
+
///
149
+
/// # Parameters
150
+
/// - `bodies` : the rigid body set from [`RapierContext`]
151
+
/// - `body1`: the first rigid-body attached to this revolute joint, obtained through [`rapier::dynamics::ImpulseJoint`] or [`rapier::dynamics::MultibodyJoint`].
152
+
/// - `body2`: the second rigid-body attached to this revolute joint, obtained through [`rapier::dynamics::ImpulseJoint`] or [`rapier::dynamics::MultibodyJoint`].
153
+
pubfnangle_from_handles(
154
+
&self,
155
+
bodies:&RigidBodySet,
156
+
body1:RigidBodyHandle,
157
+
body2:RigidBodyHandle,
158
+
) -> f32{
159
+
// NOTE: unwrap will always succeed since `Self` is known to be a revolute joint.
160
+
let joint = self.data.raw.as_revolute().unwrap();
161
+
162
+
let rb1 = &bodies[body1];
163
+
let rb2 = &bodies[body2];
164
+
joint.angle(rb1.rotation(), rb2.rotation())
165
+
}
166
+
167
+
/// The angle along the free degree of freedom of this revolute joint in `[-π, π]`.
168
+
///
169
+
/// # Parameters
170
+
/// - `bodies` : the rigid body set from [`super::super::RapierContext`]
171
+
/// - `body1`: the first rigid-body attached to this revolute joint.
172
+
/// - `body2`: the second rigid-body attached to this revolute joint.
0 commit comments