diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
| commit | 754a48b7ff6d8c58b1ee08651e60112900b60455 (patch) | |
| tree | 7d777a6c003f1f5d8f8d24f533f35a95a88957fe /src/dynamics/joint/ball_joint.rs | |
| download | rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.gz rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.bz2 rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.zip | |
First public release of Rapier.v0.1.0
Diffstat (limited to 'src/dynamics/joint/ball_joint.rs')
| -rw-r--r-- | src/dynamics/joint/ball_joint.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/dynamics/joint/ball_joint.rs b/src/dynamics/joint/ball_joint.rs new file mode 100644 index 0000000..ec255d4 --- /dev/null +++ b/src/dynamics/joint/ball_joint.rs @@ -0,0 +1,34 @@ +use crate::math::{Point, Vector}; + +#[derive(Copy, Clone)] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +/// A joint that removes all relative linear motion between a pair of points on two bodies. +pub struct BallJoint { + /// Where the ball joint is attached on the first body, expressed in the first body local frame. + pub local_anchor1: Point<f32>, + /// Where the ball joint is attached on the first body, expressed in the first body local frame. + pub local_anchor2: Point<f32>, + /// The impulse applied by this joint on the first body. + /// + /// The impulse applied to the second body is given by `-impulse`. + pub impulse: Vector<f32>, +} + +impl BallJoint { + /// Creates a new Ball joint from two anchors given on the local spaces of the respective bodies. + pub fn new(local_anchor1: Point<f32>, local_anchor2: Point<f32>) -> Self { + Self::with_impulse(local_anchor1, local_anchor2, Vector::zeros()) + } + + pub(crate) fn with_impulse( + local_anchor1: Point<f32>, + local_anchor2: Point<f32>, + impulse: Vector<f32>, + ) -> Self { + Self { + local_anchor1, + local_anchor2, + impulse, + } + } +} |
