diff options
Diffstat (limited to 'src/dynamics/joint/fixed_joint.rs')
| -rw-r--r-- | src/dynamics/joint/fixed_joint.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/dynamics/joint/fixed_joint.rs b/src/dynamics/joint/fixed_joint.rs new file mode 100644 index 0000000..0731cfb --- /dev/null +++ b/src/dynamics/joint/fixed_joint.rs @@ -0,0 +1,33 @@ +use crate::math::{Isometry, SpacialVector}; + +#[derive(Copy, Clone)] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +/// A joint that prevents all relative movement between two bodies. +/// +/// Given two frames of references, this joint aims to ensure these frame always coincide in world-space. +pub struct FixedJoint { + /// The frame of reference for the first body affected by this joint, expressed in the local frame + /// of the first body. + pub local_anchor1: Isometry<f32>, + /// The frame of reference for the second body affected by this joint, expressed in the local frame + /// of the first body. + pub local_anchor2: Isometry<f32>, + /// The impulse applied to the first body affected by this joint. + /// + /// The impulse applied to the second body affected by this joint is given by `-impulse`. + /// This combines both linear and angular impulses: + /// - In 2D, `impulse.xy()` gives the linear impulse, and `impulse.z` the angular impulse. + /// - In 3D, `impulse.xyz()` gives the linear impulse, and `(impulse[3], impulse[4], impulse[5])` the angular impulse. + pub impulse: SpacialVector<f32>, +} + +impl FixedJoint { + /// Creates a new fixed joint from the frames of reference of both bodies. + pub fn new(local_anchor1: Isometry<f32>, local_anchor2: Isometry<f32>) -> Self { + Self { + local_anchor1, + local_anchor2, + impulse: SpacialVector::zeros(), + } + } +} |
