Struct Vector3Wrapper

Source
pub struct Vector3Wrapper<T>(pub Vector3<T>);
Expand description

Treated as Pure Quaternion.

QuaternionWrapper = ScalarWrapper + Vector3Wrapper

Tuple Fields§

§0: Vector3<T>

Implementations§

Source§

impl<T: Float> Vector3Wrapper<T>

Source

pub fn new(v: Vector3<T>) -> Self

Create a new Vector3Wrapper

Source

pub fn unwrap(self) -> Vector3<T>

Returns the Vector3<T>

Source

pub fn matrix_product(self, m: DCM<T>) -> Self

Product of Vector3Wrapper and DCM.

m * self

Source

pub fn sum(self) -> ScalarWrapper<T>

Sum of the element of the vector.

Source

pub fn scale_add(self, s: ScalarWrapper<T>, b: Vector3Wrapper<T>) -> Self

Calculate s*self + b

If the fma feature is enabled, the FMA calculation is performed using the mul_add method. If not enabled, it’s computed by unfused multiply-add (s*a + b).

Source

pub fn hadamard(self, other: Vector3Wrapper<T>) -> Self

Hadamard product of vector.

Calculate a ∘ b

Source

pub fn hadamard_add(self, b: Vector3Wrapper<T>, c: Vector3Wrapper<T>) -> Self

Hadamard product and Addiction of Vector.

Calculate a ∘ b + c

If the fma feature is enabled, the FMA calculation is performed using the mul_add method. If not enabled, it’s computed by unfused multiply-add (s*a + b).

Source

pub fn dot(self, other: Vector3Wrapper<T>) -> ScalarWrapper<T>

Dot product of the vector.

Source

pub fn cross(self, other: Vector3Wrapper<T>) -> Self

Cross product of the vector.

self × other

Source

pub fn norm(self) -> ScalarWrapper<T>

Calcurate the L2 norm of the vector.

Source

pub fn normalize(self) -> Self

Normalization of vector.

If you enter a zero vector, it returns a zero vector.

§Examples
// This norm is not 1.
let v = Vector3Wrapper::<f64>::new([1.0, 2.0, 3.0]);
assert!( (1.0 - v.norm().unwrap()).abs() > 1e-12 );
 
// Now that normalized, this norm is 1!
let v_n = v.normalize();
assert!( (1.0 - v_n.norm().unwrap()).abs() < 1e-12 );
Source

pub fn inv(self) -> Self

Calculate the inverse of pure quaternion.

§Examples
let v = Vector3Wrapper::<f64>::new( [1.0, 2.0, 3.0] );
 
// Identity quaternion
let id = (v * v.inv()).unwrap();  // = (v.inv() * v).unwrap()
 
assert!( (id.0 - 1.0).abs() < 1e-12 );
assert!( id.1[0].abs() < 1e-12 );
assert!( id.1[1].abs() < 1e-12 );
assert!( id.1[2].abs() < 1e-12 );
Source

pub fn exp(self) -> QuaternionWrapper<T>

Exponential function of vector.

Trait Implementations§

Source§

impl<T: Float> Add<QuaternionWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: QuaternionWrapper<T>) -> QuaternionWrapper<T>

Performs the + operation. Read more
Source§

impl<T: Float> Add<ScalarWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: ScalarWrapper<T>) -> QuaternionWrapper<T>

Performs the + operation. Read more
Source§

impl<T: Float> Add<Vector3Wrapper<T>> for QuaternionWrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: Vector3Wrapper<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Float> Add<Vector3Wrapper<T>> for ScalarWrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: Vector3Wrapper<T>) -> QuaternionWrapper<T>

Performs the + operation. Read more
Source§

impl<T: Float> Add for Vector3Wrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: Vector3Wrapper<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Float> AddAssign for Vector3Wrapper<T>

Source§

fn add_assign(&mut self, other: Vector3Wrapper<T>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Vector3Wrapper<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Vector3Wrapper<T>

Source§

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

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

impl<T: Float> Div<ScalarWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the / operator.
Source§

fn div(self, other: ScalarWrapper<T>) -> Self

Performs the / operation. Read more
Source§

impl<T: Float> Mul<QuaternionWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: QuaternionWrapper<T>) -> QuaternionWrapper<T>

Performs the * operation. Read more
Source§

impl<T: Float> Mul<ScalarWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: ScalarWrapper<T>) -> Self

Performs the * operation. Read more
Source§

impl<T: Float> Mul<Vector3Wrapper<T>> for QuaternionWrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Vector3Wrapper<T>) -> Self

Performs the * operation. Read more
Source§

impl<T: Float> Mul<Vector3Wrapper<T>> for ScalarWrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Vector3Wrapper<T>) -> Vector3Wrapper<T>

Performs the * operation. Read more
Source§

impl<T: Float> Mul for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Vector3Wrapper<T>) -> QuaternionWrapper<T>

Performs the * operation. Read more
Source§

impl<T: Float> Neg for Vector3Wrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: Float> Sub<QuaternionWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: QuaternionWrapper<T>) -> QuaternionWrapper<T>

Performs the - operation. Read more
Source§

impl<T: Float> Sub<ScalarWrapper<T>> for Vector3Wrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: ScalarWrapper<T>) -> QuaternionWrapper<T>

Performs the - operation. Read more
Source§

impl<T: Float> Sub<Vector3Wrapper<T>> for QuaternionWrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Vector3Wrapper<T>) -> Self

Performs the - operation. Read more
Source§

impl<T: Float> Sub<Vector3Wrapper<T>> for ScalarWrapper<T>

Source§

type Output = QuaternionWrapper<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Vector3Wrapper<T>) -> QuaternionWrapper<T>

Performs the - operation. Read more
Source§

impl<T: Float> Sub for Vector3Wrapper<T>

Source§

type Output = Vector3Wrapper<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Vector3Wrapper<T>) -> Self

Performs the - operation. Read more
Source§

impl<T: Float> SubAssign for Vector3Wrapper<T>

Source§

fn sub_assign(&mut self, other: Vector3Wrapper<T>)

Performs the -= operation. Read more
Source§

impl<T: Copy> Copy for Vector3Wrapper<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vector3Wrapper<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vector3Wrapper<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vector3Wrapper<T>
where T: Send,

§

impl<T> Sync for Vector3Wrapper<T>
where T: Sync,

§

impl<T> Unpin for Vector3Wrapper<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vector3Wrapper<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.