#[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_components_f64(components: [f64; D]) -> Self
pub fn from_components_f64(components: [f64; D]) -> Self
Construct a Vector from f64 components
Panics
Panics, if the components can not be converted to Scalar. See
Scalar::from_f64, which this method uses internally.
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<Vector<D>> for Vector<D>
impl<const D: usize> AbsDiffEq<Vector<D>> 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>where
S: Into<Scalar>,
impl<S, const D: usize> MulAssign<S> for Vector<D>where S: Into<Scalar>,
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> PartialEq<Vector<D>> for Vector<D>
impl<const D: usize> PartialEq<Vector<D>> for Vector<D>
source§impl<const D: usize> PartialOrd<Vector<D>> for Vector<D>
impl<const D: usize> PartialOrd<Vector<D>> for Vector<D>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl<const D: usize> Copy for Vector<D>
impl<const D: usize> Eq for Vector<D>
impl<const D: usize> StructuralEq for Vector<D>
impl<const D: usize> StructuralPartialEq for Vector<D>
Auto Trait Implementations§
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§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.