From 7cca67752328018d3b19aa7e7e6e75f91d2779b0 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 26 Mar 2023 15:44:59 +0200 Subject: Add methods to customize a SphericalJoint’s local reference frames. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dynamics/joint/spherical_joint.rs | 47 ++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dynamics/joint/spherical_joint.rs b/src/dynamics/joint/spherical_joint.rs index bce393c..d7f4d0f 100644 --- a/src/dynamics/joint/spherical_joint.rs +++ b/src/dynamics/joint/spherical_joint.rs @@ -66,6 +66,34 @@ impl SphericalJoint { self } + /// Gets both the joint anchor and the joint’s reference orientation relative to the first + /// rigid-body’s local-space. + #[must_use] + pub fn local_frame1(&self) -> &Isometry { + &self.data.local_frame1 + } + + /// Sets both the joint anchor and the joint’s reference orientation relative to the first + /// rigid-body’s local-space. + pub fn set_local_frame1(&mut self, local_frame: Isometry) -> &mut Self { + self.data.set_local_frame1(local_frame); + self + } + + /// Gets both the joint anchor and the joint’s reference orientation relative to the second + /// rigid-body’s local-space. + #[must_use] + pub fn local_frame2(&self) -> &Isometry { + &self.data.local_frame2 + } + + /// Sets both the joint anchor and the joint’s reference orientation relative to the second + /// rigid-body’s local-space. + pub fn set_local_frame2(&mut self, local_frame: Isometry) -> &mut Self { + self.data.set_local_frame2(local_frame); + self + } + /// The motor affecting the joint’s rotational degree of freedom along the specified axis. #[must_use] pub fn motor(&self, axis: JointAxis) -> Option<&JointMotor> { @@ -128,7 +156,8 @@ impl SphericalJoint { self.data.limits(axis) } - /// Sets the `[min,max]` limit angles attached bodies can translate along the joint’s principal axis. + /// Sets the `[min,max]` limit angles attached bodies can translate along the joint’s principal + /// axis. pub fn set_limits(&mut self, axis: JointAxis, limits: [Real; 2]) -> &mut Self { self.data.set_limits(axis, limits); self @@ -179,6 +208,22 @@ impl SphericalJointBuilder { self } + /// Sets both the joint anchor and the joint’s reference orientation relative to the first + /// rigid-body’s local-space. + #[must_use] + pub fn local_frame1(mut self, frame1: Isometry) -> Self { + self.0.set_local_frame1(frame1); + self + } + + /// Sets both the joint anchor and the joint’s reference orientation relative to the second + /// rigid-body’s local-space. + #[must_use] + pub fn local_frame2(mut self, frame2: Isometry) -> Self { + self.0.set_local_frame2(frame2); + self + } + /// Set the spring-like model used by the motor to reach the desired target velocity and position. #[must_use] pub fn motor_model(mut self, axis: JointAxis, model: MotorModel) -> Self { -- cgit From b6fdfd11ad761e218971b1af7b883207027f9414 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 26 Mar 2023 15:57:31 +0200 Subject: Add missing import --- src/dynamics/joint/spherical_joint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dynamics/joint/spherical_joint.rs b/src/dynamics/joint/spherical_joint.rs index d7f4d0f..6f2dc39 100644 --- a/src/dynamics/joint/spherical_joint.rs +++ b/src/dynamics/joint/spherical_joint.rs @@ -1,6 +1,6 @@ use crate::dynamics::joint::{GenericJoint, GenericJointBuilder, JointAxesMask}; use crate::dynamics::{JointAxis, JointMotor, MotorModel}; -use crate::math::{Point, Real}; +use crate::math::{Isometry, Point, Real}; use super::JointLimits; -- cgit