#[repr(C)]pub struct Vector<const D: usize> {
pub components: [Scalar; D],
}Expand description
An n-dimensional vector
The dimensionality of the vector is defined by the const generic D
parameter.
Fields§
§components: [Scalar; D]The vector components
Implementations§
Source§impl<const D: usize> Vector<D>
impl<const D: usize> Vector<D>
Sourcepub fn from_component(scalar: impl Into<Scalar>) -> Self
pub fn from_component(scalar: impl Into<Scalar>) -> Self
Create a vector whose components are all equal
Sourcepub fn to_uv(self) -> Vector<2>
pub fn to_uv(self) -> Vector<2>
Convert the vector into a 2-dimensional vector
If the vector is 0-, or 1-dimensional, the missing components will be initialized to zero.
If the vector has higher dimensionality than two, the superfluous components will be discarded.
Sourcepub fn to_xyz(self) -> Vector<3>
pub fn to_xyz(self) -> Vector<3>
Convert the vector into a 3-dimensional vector
If the vector is 0-, 1-, or 2-dimensional, the missing components will be initialized to zero.
If the vector has higher dimensionality than three, the superfluous components will be discarded.
Sourcepub fn scalar_projection_onto(&self, other: &Self) -> Scalar
pub fn scalar_projection_onto(&self, other: &Self) -> Scalar
Compute the scalar projection of this vector onto another
Source§impl Vector<2>
impl Vector<2>
Sourcepub fn is_between(&self, others: [impl Into<Self>; 2]) -> bool
pub fn is_between(&self, others: [impl Into<Self>; 2]) -> bool
Determine whether this vector is between two other vectors
Trait Implementations§
Source§impl<const D: usize> AbsDiffEq for Vector<D>
impl<const D: usize> AbsDiffEq for Vector<D>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.Source§impl<const D: usize> From<Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>> for Vector<D>
impl<const D: usize> From<Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>> for Vector<D>
Source§impl<S, const D: usize> MulAssign<S> for Vector<D>
impl<S, const D: usize> MulAssign<S> for Vector<D>
Source§fn mul_assign(&mut self, rhs: S)
fn mul_assign(&mut self, rhs: S)
*= operation. Read moreSource§impl<const D: usize> Ord for Vector<D>
impl<const D: usize> Ord for Vector<D>
Source§impl<const D: usize> PartialOrd for Vector<D>
impl<const D: usize> PartialOrd for Vector<D>
impl<const D: usize> Copy for Vector<D>
impl<const D: usize> Eq for Vector<D>
impl<const D: usize> StructuralPartialEq for Vector<D>
Auto Trait Implementations§
impl<const D: usize> Freeze for Vector<D>
impl<const D: usize> RefUnwindSafe for Vector<D>
impl<const D: usize> Send for Vector<D>
impl<const D: usize> Sync for Vector<D>
impl<const D: usize> Unpin for Vector<D>
impl<const D: usize> UnwindSafe for Vector<D>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.