Skip to main content

Wrench

Struct Wrench 

Source
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>

Source

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]));
Source

pub fn zeros() -> Self

The zero wrench.

use multicalc::spatial::Wrench;
assert_eq!(Wrench::<f64>::zeros().as_array(), [0.0; 6]);
Source

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]));
Source

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]);
Source

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]));
Source

pub fn to_vector(self) -> Vector6D<T>

The wrench as a flat [f; τ] Vector6D.

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.to_vector(), Vector::new([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]));
Source

pub fn force(self) -> Vector3D<T>

The force part f.

Source

pub fn torque(self) -> Vector3D<T>

The torque (moment) part τ.

Source

pub fn scale(self, scalar: T) -> Self

Multiplies both parts by scalar.

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.scale(2.0).as_array(), [2.0, 4.0, 6.0, 8.0, 10.0, 12.0]);

Trait Implementations§

Source§

impl<T: Numeric> Add for Wrench<T>

Source§

type Output = Wrench<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone + Numeric> Clone for Wrench<T>

Source§

fn clone(&self) -> Wrench<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy + Numeric> Copy for Wrench<T>

Source§

impl<T: Debug + Numeric> Debug for Wrench<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Numeric> Default for Wrench<T>

Source§

fn default() -> Self

Returns the zero wrench as default.

use multicalc::Wrench;

let default_wrench = Wrench::default();
let wrench = Wrench::<f64>::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);

assert_eq!(wrench + default_wrench, wrench);
Source§

impl<T: Numeric> From<Vector<6, T>> for Wrench<T>

Source§

fn from(v: Vector6D<T>) -> Self

Reinterprets a flat [f; τ] Vector6D as a wrench.

Source§

impl<T: Numeric> From<Wrench<T>> for Vector6D<T>

Source§

fn from(w: Wrench<T>) -> Self

Flattens a wrench into [f; τ].

Source§

impl<T: Numeric> Neg for Wrench<T>

Source§

type Output = Wrench<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq + Numeric> PartialEq for Wrench<T>

Source§

fn eq(&self, other: &Wrench<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialEq + Numeric> StructuralPartialEq for Wrench<T>

Source§

impl<T: Numeric> Sub for Wrench<T>

Source§

type Output = Wrench<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.