nphysics2d/joint/
fixed_joint.rs1use na::{DVectorSliceMut, RealField};
2
3use crate::joint::Joint;
4
5use crate::math::{Isometry, JacobianSliceMut, Translation, Vector, Velocity};
6use crate::solver::IntegrationParameters;
7
8#[derive(Copy, Clone, Debug)]
10pub struct FixedJoint<N: RealField + Copy> {
11 body_to_parent: Isometry<N>,
12}
13
14impl<N: RealField + Copy> FixedJoint<N> {
15 pub fn new(pos_wrt_body: Isometry<N>) -> Self {
20 FixedJoint {
21 body_to_parent: pos_wrt_body.inverse(),
22 }
23 }
24}
25
26impl<N: RealField + Copy> Joint<N> for FixedJoint<N> {
27 fn ndofs(&self) -> usize {
28 0
29 }
30
31 fn body_to_parent(&self, parent_shift: &Vector<N>, body_shift: &Vector<N>) -> Isometry<N> {
32 let parent_trans = Translation::from(*parent_shift);
33 let body_trans = Translation::from(*body_shift);
34 parent_trans * self.body_to_parent * body_trans
35 }
36
37 fn update_jacobians(&mut self, _: &Vector<N>, _: &[N]) {}
38
39 fn jacobian(&self, _: &Isometry<N>, _: &mut JacobianSliceMut<N>) {}
40
41 fn jacobian_dot(&self, _: &Isometry<N>, _: &mut JacobianSliceMut<N>) {}
42
43 fn jacobian_dot_veldiff_mul_coordinates(
44 &self,
45 _: &Isometry<N>,
46 _: &[N],
47 _: &mut JacobianSliceMut<N>,
48 ) {
49 }
50
51 fn integrate(&mut self, _: &IntegrationParameters<N>, _: &[N]) {}
52 fn apply_displacement(&mut self, _: &[N]) {}
53
54 fn jacobian_mul_coordinates(&self, _: &[N]) -> Velocity<N> {
55 Velocity::zero()
56 }
57
58 fn jacobian_dot_mul_coordinates(&self, _: &[N]) -> Velocity<N> {
59 Velocity::zero()
60 }
61
62 fn default_damping(&self, _: &mut DVectorSliceMut<N>) {}
63
64 #[inline]
65 fn clone(&self) -> Box<dyn Joint<N>> {
66 Box::new(*self)
67 }
68}