pub struct Vector<const N: usize>(pub [f64; N]);Expand description
An N-dimensional vector representing a direction or displacement.
Tuple Fields§
§0: [f64; N]Implementations§
Source§impl<const N: usize> Vector<N>
impl<const N: usize> Vector<N>
Sourcepub fn length_squared(self) -> f64
pub fn length_squared(self) -> f64
Squared Euclidean length (avoids a sqrt).
Sourcepub fn normalize(self) -> Result<Self, MathError>
pub fn normalize(self) -> Result<Self, MathError>
Return a unit-length vector in the same direction.
§Errors
Returns MathError::ZeroVector if the vector is zero, has
denormalized length (< f64::MIN_POSITIVE), or has overflowed
length (non-finite).
Trait Implementations§
Source§impl<const N: usize> Add<Vector<N>> for Position<N>
Translate a point by a vector: point + vector → point.
impl<const N: usize> Add<Vector<N>> for Position<N>
Translate a point by a vector: point + vector → point.
Source§impl<const N: usize> AddAssign for Vector<N>
impl<const N: usize> AddAssign for Vector<N>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl<const N: usize> Copy for Vector<N>
Source§impl<'de, const N: usize> Deserialize<'de> for Vector<N>
Available on crate feature serde only.
impl<'de, const N: usize> Deserialize<'de> for Vector<N>
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl<const N: usize> StructuralPartialEq for Vector<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Vector<N>
impl<const N: usize> RefUnwindSafe for Vector<N>
impl<const N: usize> Send for Vector<N>
impl<const N: usize> Sync for Vector<N>
impl<const N: usize> Unpin for Vector<N>
impl<const N: usize> UnsafeUnpin for Vector<N>
impl<const N: usize> UnwindSafe for Vector<N>
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