#[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> PartialEq for Vector<D>
impl<const D: usize> PartialEq for Vector<D>
source§impl<const D: usize> PartialOrd for Vector<D>
impl<const D: usize> PartialOrd 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> 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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§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.