Skip to main content

VectorPrecise

Struct VectorPrecise 

Source
pub struct VectorPrecise<const L: usize> {
    pub data: [r32; L],
}
Expand description

Vector type using rational components - allows for higher precision + implementation of Eq and Hash. Length of L, components are r32, indexable by usize index.

Fields§

§data: [r32; L]

Array of r32 components.

Implementations§

Source§

impl<const L: usize> VectorPrecise<L>

Source

pub fn new(data: [r32; L]) -> Self

Returns a new Vector of length L from an array of f32 with the same length.

Source

pub fn dot(&self, other: VectorPrecise<L>) -> r32

Dot product with another Vector of same length.

Source

pub fn as_row(&self) -> MatrixPrecise<1, L>

Returns the Vector as a Matrix with 1 row and L columns - aka the Vector as a single row matrix.

Source

pub fn as_col(&self) -> MatrixPrecise<L, 1>

Returns the Vector as a Matrix with L rows and 1 column - aka the Vector as a single column matrix.

Source

pub fn vec_add(&self, other: Self) -> Self

Utility function for adding vectors - used to implement std::ops.

Source

pub fn vec_mul(&self, other: Self) -> Self

Utility function for multiplying vectors - used to implement std::ops.

Source

pub fn rational_mul(&self, other: r32) -> Self

Utility function for multiplying a vector by a rational - used to implement std::ops.

Source

pub fn recip(&self) -> Self

Utility function for getting the reciprocal of the vector, component wise - used to implement std::ops.

Source

pub fn sum(&self) -> r32

Returns the sum of the components of the vector.

Source

pub fn sq_sum(&self) -> r32

Returns the sum of the squared components of the vector, i.e. the squared magnitude of the vector.

Source

pub fn normalised(&self) -> Self

Returns a normalised copy of the vector.

Source§

impl VectorPrecise<2>

Source

pub fn heading(&self) -> r32

Trait Implementations§

Source§

impl<const L: usize> Add for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the + operator.
Source§

fn add(self, other: VectorPrecise<L>) -> Self

Performs the + operation. Read more
Source§

impl<const L: usize> Clone for VectorPrecise<L>

Source§

fn clone(&self) -> VectorPrecise<L>

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<const L: usize> Debug for VectorPrecise<L>

Source§

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

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

impl<const L: usize> Default for VectorPrecise<L>

Source§

fn default() -> VectorPrecise<L>

Returns the “default value” for a type. Read more
Source§

impl<const L: usize> Display for VectorPrecise<L>

Source§

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

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

impl<const L: usize> Div<r32> for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the / operator.
Source§

fn div(self, other: r32) -> Self

Performs the / operation. Read more
Source§

impl<const L: usize> Div for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the / operator.
Source§

fn div(self, other: VectorPrecise<L>) -> Self

Performs the / operation. Read more
Source§

impl<const L: usize> From<Vector<L>> for VectorPrecise<L>

Source§

fn from(v: Vector<L>) -> Self

Converts to this type from the input type.
Source§

impl<const L: usize> From<VectorPrecise<L>> for Vector<L>

Source§

fn from(v: VectorPrecise<L>) -> Self

Converts to this type from the input type.
Source§

impl<const L: usize> Hash for VectorPrecise<L>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const L: usize> Identity for VectorPrecise<L>

Source§

impl<const L: usize> Index<usize> for VectorPrecise<L>

Source§

type Output = r32

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &r32

Performs the indexing (container[index]) operation. Read more
Source§

impl<const L: usize> IndexMut<usize> for VectorPrecise<L>

Source§

fn index_mut(&mut self, index: usize) -> &mut r32

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<const L: usize> Magnitude for VectorPrecise<L>

Source§

impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>

Source§

type Output = VectorPrecise<B>

The resulting type after applying the * operator.
Source§

fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>

Performs the * operation. Read more
Source§

impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>

Source§

type Output = VectorPrecise<A>

The resulting type after applying the * operator.
Source§

fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>

Performs the * operation. Read more
Source§

impl<const L: usize> Mul<VectorPrecise<L>> for r32

Source§

type Output = VectorPrecise<L>

The resulting type after applying the * operator.
Source§

fn mul(self, other: VectorPrecise<L>) -> VectorPrecise<L>

Performs the * operation. Read more
Source§

impl<const L: usize> Mul<r32> for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the * operator.
Source§

fn mul(self, other: r32) -> Self

Performs the * operation. Read more
Source§

impl<const L: usize> Mul for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the * operator.
Source§

fn mul(self, other: VectorPrecise<L>) -> Self

Performs the * operation. Read more
Source§

impl<const L: usize> PartialEq for VectorPrecise<L>

Source§

fn eq(&self, other: &VectorPrecise<L>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const L: usize> Sub for VectorPrecise<L>

Source§

type Output = VectorPrecise<L>

The resulting type after applying the - operator.
Source§

fn sub(self, other: VectorPrecise<L>) -> Self

Performs the - operation. Read more
Source§

impl<const L: usize> Copy for VectorPrecise<L>

Source§

impl<const L: usize> Eq for VectorPrecise<L>

Source§

impl<const L: usize> StructuralPartialEq for VectorPrecise<L>

Auto Trait Implementations§

§

impl<const L: usize> Freeze for VectorPrecise<L>

§

impl<const L: usize> RefUnwindSafe for VectorPrecise<L>

§

impl<const L: usize> Send for VectorPrecise<L>

§

impl<const L: usize> Sync for VectorPrecise<L>

§

impl<const L: usize> Unpin for VectorPrecise<L>

§

impl<const L: usize> UnsafeUnpin for VectorPrecise<L>

§

impl<const L: usize> UnwindSafe for VectorPrecise<L>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.