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>
impl<const L: usize> VectorPrecise<L>
Sourcepub fn new(data: [r32; L]) -> Self
pub fn new(data: [r32; L]) -> Self
Returns a new Vector of length L from an array of f32 with the same length.
Sourcepub fn dot(&self, other: VectorPrecise<L>) -> r32
pub fn dot(&self, other: VectorPrecise<L>) -> r32
Dot product with another Vector of same length.
Sourcepub fn as_row(&self) -> MatrixPrecise<1, L>
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.
Sourcepub fn as_col(&self) -> MatrixPrecise<L, 1>
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.
Sourcepub fn vec_add(&self, other: Self) -> Self
pub fn vec_add(&self, other: Self) -> Self
Utility function for adding vectors - used to implement std::ops.
Sourcepub fn vec_mul(&self, other: Self) -> Self
pub fn vec_mul(&self, other: Self) -> Self
Utility function for multiplying vectors - used to implement std::ops.
Sourcepub fn rational_mul(&self, other: r32) -> Self
pub fn rational_mul(&self, other: r32) -> Self
Utility function for multiplying a vector by a rational - used to implement std::ops.
Sourcepub fn recip(&self) -> Self
pub fn recip(&self) -> Self
Utility function for getting the reciprocal of the vector, component wise - used to implement std::ops.
Sourcepub fn sq_sum(&self) -> r32
pub fn sq_sum(&self) -> r32
Returns the sum of the squared components of the vector, i.e. the squared magnitude of the vector.
Sourcepub fn normalised(&self) -> Self
pub fn normalised(&self) -> Self
Returns a normalised copy of the vector.
Trait Implementations§
Source§impl<const L: usize> Add for VectorPrecise<L>
impl<const L: usize> Add for VectorPrecise<L>
Source§type Output = VectorPrecise<L>
type Output = VectorPrecise<L>
+ operator.Source§fn add(self, other: VectorPrecise<L>) -> Self
fn add(self, other: VectorPrecise<L>) -> Self
+ operation. Read moreSource§impl<const L: usize> Clone for VectorPrecise<L>
impl<const L: usize> Clone for VectorPrecise<L>
Source§fn clone(&self) -> VectorPrecise<L>
fn clone(&self) -> VectorPrecise<L>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const L: usize> Debug for VectorPrecise<L>
impl<const L: usize> Debug for VectorPrecise<L>
Source§impl<const L: usize> Default for VectorPrecise<L>
impl<const L: usize> Default for VectorPrecise<L>
Source§fn default() -> VectorPrecise<L>
fn default() -> VectorPrecise<L>
Source§impl<const L: usize> Display for VectorPrecise<L>
impl<const L: usize> Display for VectorPrecise<L>
Source§impl<const L: usize> Div for VectorPrecise<L>
impl<const L: usize> Div for VectorPrecise<L>
Source§type Output = VectorPrecise<L>
type Output = VectorPrecise<L>
/ operator.Source§fn div(self, other: VectorPrecise<L>) -> Self
fn div(self, other: VectorPrecise<L>) -> Self
/ operation. Read moreSource§impl<const L: usize> From<VectorPrecise<L>> for Vector<L>
impl<const L: usize> From<VectorPrecise<L>> for Vector<L>
Source§fn from(v: VectorPrecise<L>) -> Self
fn from(v: VectorPrecise<L>) -> Self
Source§impl<const L: usize> Hash for VectorPrecise<L>
impl<const L: usize> Hash for VectorPrecise<L>
Source§impl<const L: usize> Identity for VectorPrecise<L>
impl<const L: usize> Identity for VectorPrecise<L>
fn identity() -> VectorPrecise<L>
Source§impl<const L: usize> Magnitude for VectorPrecise<L>
impl<const L: usize> Magnitude for VectorPrecise<L>
Source§impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>
impl<const A: usize, const B: usize> Mul<MatrixPrecise<A, B>> for VectorPrecise<A>
Source§type Output = VectorPrecise<B>
type Output = VectorPrecise<B>
* operator.Source§fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>
fn mul(self, other: MatrixPrecise<A, B>) -> VectorPrecise<B>
* operation. Read moreSource§impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>
impl<const A: usize, const B: usize> Mul<VectorPrecise<B>> for MatrixPrecise<A, B>
Source§type Output = VectorPrecise<A>
type Output = VectorPrecise<A>
* operator.Source§fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>
fn mul(self, other: VectorPrecise<B>) -> VectorPrecise<A>
* operation. Read moreSource§impl<const L: usize> Mul<VectorPrecise<L>> for r32
impl<const L: usize> Mul<VectorPrecise<L>> for r32
Source§type Output = VectorPrecise<L>
type Output = VectorPrecise<L>
* operator.Source§fn mul(self, other: VectorPrecise<L>) -> VectorPrecise<L>
fn mul(self, other: VectorPrecise<L>) -> VectorPrecise<L>
* operation. Read moreSource§impl<const L: usize> Mul for VectorPrecise<L>
impl<const L: usize> Mul for VectorPrecise<L>
Source§type Output = VectorPrecise<L>
type Output = VectorPrecise<L>
* operator.Source§fn mul(self, other: VectorPrecise<L>) -> Self
fn mul(self, other: VectorPrecise<L>) -> Self
* operation. Read moreSource§impl<const L: usize> PartialEq for VectorPrecise<L>
impl<const L: usize> PartialEq for VectorPrecise<L>
Source§fn eq(&self, other: &VectorPrecise<L>) -> bool
fn eq(&self, other: &VectorPrecise<L>) -> bool
self and other values to be equal, and is used by ==.Source§impl<const L: usize> Sub for VectorPrecise<L>
impl<const L: usize> Sub for VectorPrecise<L>
Source§type Output = VectorPrecise<L>
type Output = VectorPrecise<L>
- operator.Source§fn sub(self, other: VectorPrecise<L>) -> Self
fn sub(self, other: VectorPrecise<L>) -> Self
- operation. Read more