diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-02-11 18:52:07 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-02-11 18:52:07 +0100 |
| commit | cc80e40067d100d0f519c9a20abb020726dd8514 (patch) | |
| tree | c182c675e883b7e29eb38932d6f702af707dbd8c /src/dynamics/joint | |
| parent | 5b80c4efbf93ad1294c9d3d390d8c8f090681b0e (diff) | |
| download | rapier-cc80e40067d100d0f519c9a20abb020726dd8514.tar.gz rapier-cc80e40067d100d0f519c9a20abb020726dd8514.tar.bz2 rapier-cc80e40067d100d0f519c9a20abb020726dd8514.zip | |
More experiments with the way the generic joint is stabilized.
Diffstat (limited to 'src/dynamics/joint')
| -rw-r--r-- | src/dynamics/joint/generic_joint.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/dynamics/joint/generic_joint.rs b/src/dynamics/joint/generic_joint.rs index cfea537..2aa9a51 100644 --- a/src/dynamics/joint/generic_joint.rs +++ b/src/dynamics/joint/generic_joint.rs @@ -1,4 +1,6 @@ +use crate::dynamics::RevoluteJoint; use crate::math::{Isometry, Real, SpacialVector, SPATIAL_DIM}; +use crate::na::{Rotation3, UnitQuaternion}; #[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] @@ -44,3 +46,19 @@ impl GenericJoint { } } } + +impl From<RevoluteJoint> for GenericJoint { + fn from(joint: RevoluteJoint) -> Self { + let basis1 = [joint.local_axis1, joint.basis1[0], joint.basis1[1]]; + let basis2 = [joint.local_axis2, joint.basis2[0], joint.basis2[1]]; + let quat1 = UnitQuaternion::from_basis_unchecked(&basis1[..]); + let quat2 = UnitQuaternion::from_basis_unchecked(&basis2[..]); + let local_anchor1 = Isometry::from_parts(joint.local_anchor1.coords.into(), quat1); + let local_anchor2 = Isometry::from_parts(joint.local_anchor2.coords.into(), quat2); + + let mut result = Self::new(local_anchor1, local_anchor2); + result.min_position[3] = -Real::MAX; + result.max_position[3] = Real::MAX; + result + } +} |
