pub struct TwoLinkArm { /* private fields */ }Expand description
A planar two-link arm: the textbook arm with a closed-form inverse.
Two links of fixed length in a plane, with a shoulder and an elbow joint. tip
is forward kinematics; joints_for is the analytic inverse, returning
the shoulder and elbow angles that place the hand at a target, for the chosen Elbow branch.
§Examples
use pamoja_kit::{Elbow, TwoLinkArm};
let arm = TwoLinkArm::new(1.0, 1.0);
// Place the hand, then recover the joint angles for it.
let (x, y) = arm.tip(0.5, 0.7);
let (q1, q2) = arm.joints_for(x, y, Elbow::Up).unwrap();
assert!((q1 - 0.5).abs() < 1e-4 && (q2 - 0.7).abs() < 1e-4);
// A target beyond the arm's reach has no solution.
assert!(arm.joints_for(5.0, 0.0, Elbow::Up).is_none());Implementations§
Source§impl TwoLinkArm
impl TwoLinkArm
Sourcepub fn reach(&self) -> (f32, f32)
pub fn reach(&self) -> (f32, f32)
Returns the closest and farthest distances the hand can reach from the shoulder.
§Returns
(min, max), where min is |l1 - l2| and max is l1 + l2.
Trait Implementations§
Source§impl Clone for TwoLinkArm
impl Clone for TwoLinkArm
Source§fn clone(&self) -> TwoLinkArm
fn clone(&self) -> TwoLinkArm
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TwoLinkArm
Auto Trait Implementations§
impl Freeze for TwoLinkArm
impl RefUnwindSafe for TwoLinkArm
impl Send for TwoLinkArm
impl Sync for TwoLinkArm
impl Unpin for TwoLinkArm
impl UnsafeUnpin for TwoLinkArm
impl UnwindSafe for TwoLinkArm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more