pub struct Wrench<T: Numeric = f64> { /* private fields */ }Expand description
A spatial force (wrench), stored force-first in the [force; torque] ordering — reciprocal to a
Twist, so the two line up component-for-component.
Like Twist, the type owns its layout: the only value constructor takes the force and torque
parts by name, and the flat converters emit [f; τ]. Add/Sub/Neg/scale
act component-wise; the spatial algebra (coordinate transforms, the twist · wrench power
product) is not defined here.
use multicalc::spatial::Wrench;
let a = Wrench::from_array([1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]);
let b = Wrench::from_array([1.0_f64; 6]);
assert_eq!((a + b).as_array(), [2.0, 3.0, 4.0, 5.0, 6.0, 7.0]);
assert_eq!((a - b).as_array(), [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]);
assert_eq!((-a).as_array(), [-1.0, -2.0, -3.0, -4.0, -5.0, -6.0]);
assert_eq!(a.scale(2.0).as_array(), [2.0, 4.0, 6.0, 8.0, 10.0, 12.0]);Implementations§
Source§impl<T: Numeric> Wrench<T>
impl<T: Numeric> Wrench<T>
Sourcepub fn new(force: Vector3D<T>, torque: Vector3D<T>) -> Self
pub fn new(force: Vector3D<T>, torque: Vector3D<T>) -> Self
A wrench from its force and torque parts.
use multicalc::linear_algebra::Vector;
use multicalc::spatial::Wrench;
let force = Vector::new([1.0_f64, 2.0, 3.0]);
let torque = Vector::new([4.0, 5.0, 6.0]);
let w = Wrench::new(force, torque);
assert_eq!(w.force(), Vector::new([1.0, 2.0, 3.0]));
assert_eq!(w.torque(), Vector::new([4.0, 5.0, 6.0]));Sourcepub fn zeros() -> Self
pub fn zeros() -> Self
The zero wrench.
use multicalc::spatial::Wrench;
assert_eq!(Wrench::<f64>::zeros().as_array(), [0.0; 6]);Sourcepub fn from_array(a: [T; 6]) -> Self
pub fn from_array(a: [T; 6]) -> Self
A wrench from a [fx, fy, fz, τx, τy, τz] array.
use multicalc::linear_algebra::Vector;
use multicalc::spatial::Wrench;
let w = Wrench::from_array([1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]);
assert_eq!(w.torque(), Vector::new([4.0, 5.0, 6.0]));Sourcepub fn as_array(self) -> [T; 6]
pub fn as_array(self) -> [T; 6]
The wrench as a [fx, fy, fz, τx, τy, τz] array.
use multicalc::spatial::Wrench;
let w = Wrench::from_array([1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]);
assert_eq!(w.as_array(), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);Sourcepub fn from_vector(v: Vector6D<T>) -> Self
pub fn from_vector(v: Vector6D<T>) -> Self
A wrench from a flat [f; τ] Vector6D.
use multicalc::linear_algebra::Vector;
use multicalc::spatial::Wrench;
let w = Wrench::from_vector(Vector::new([1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]));
assert_eq!(w.force(), Vector::new([1.0, 2.0, 3.0]));Trait Implementations§
impl<T: Copy + Numeric> Copy for Wrench<T>
impl<T: PartialEq + Numeric> StructuralPartialEq for Wrench<T>
Auto Trait Implementations§
impl<T> Freeze for Wrench<T>where
T: Freeze,
impl<T> RefUnwindSafe for Wrench<T>where
T: RefUnwindSafe,
impl<T> Send for Wrench<T>where
T: Send,
impl<T> Sync for Wrench<T>where
T: Sync,
impl<T> Unpin for Wrench<T>where
T: Unpin,
impl<T> UnsafeUnpin for Wrench<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Wrench<T>where
T: UnwindSafe,
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