pub struct Dir<T: Scalar, const N: usize, S: Space>(/* private fields */);Expand description
A direction in N-dimensional space, represented by a unit vector.
The API of this type is fairly limited to ensure it always contains a unit vector.
Implementations§
Source§impl<T: Scalar, const N: usize, S: Space> Dir<T, N, S>
impl<T: Scalar, const N: usize, S: Space> Dir<T, N, S>
Sourcepub fn from_vec(v: Vector<T, N, S>) -> Selfwhere
T: Float,
pub fn from_vec(v: Vector<T, N, S>) -> Selfwhere
T: Float,
Returns the direction of the given vector. If v is the null vector,
this function panics.
Sourcepub fn from_unit_vec_unchecked(v: Vector<T, N, S>) -> Self
pub fn from_unit_vec_unchecked(v: Vector<T, N, S>) -> Self
Returns the wrapped input vector, assuming it is normalized.
Sourcepub fn to_unit_vec(&self) -> Vector<T, N, S>
pub fn to_unit_vec(&self) -> Vector<T, N, S>
Returns the unit vector that represents this direction.
Sourcepub fn to_point(&self) -> Point<T, N, S>
pub fn to_point(&self) -> Point<T, N, S>
Returns the point corresponding to this unit vector (a point on the unit sphere).
Sourcepub fn in_space<Target: Space>(self) -> Dir<T, N, Target>
pub fn in_space<Target: Space>(self) -> Dir<T, N, Target>
Reinterprets this direction as being in the space Target instead of
S. Before calling this, make sure this operation makes semantic sense
and don’t just use it to get rid of compiler errors.
Source§impl<T: Scalar, S: Space> Dir<T, 2, S>
impl<T: Scalar, S: Space> Dir<T, 2, S>
Sourcepub fn new(x: T, y: T) -> Selfwhere
T: Float,
pub fn new(x: T, y: T) -> Selfwhere
T: Float,
Creates a Dir by normalizing the vector specified by the given
coordinates.
Sourcepub const fn new_unchecked(x: T, y: T) -> Self
pub const fn new_unchecked(x: T, y: T) -> Self
Creates a Dir without checking that the given values form a unit
vector.
Source§impl<T: Scalar, S: Space> Dir<T, 3, S>
impl<T: Scalar, S: Space> Dir<T, 3, S>
Sourcepub fn new(x: T, y: T, z: T) -> Selfwhere
T: Float,
pub fn new(x: T, y: T, z: T) -> Selfwhere
T: Float,
Creates a Dir by normalizing the vector specified by the given
coordinates.
Sourcepub const fn new_unchecked(x: T, y: T, z: T) -> Self
pub const fn new_unchecked(x: T, y: T, z: T) -> Self
Creates a Dir without checking that the given values form a unit
vector.
Trait Implementations§
Source§impl<T: Float, const N: usize, S: Space> From<Vector<T, N, S>> for Dir<T, N, S>
If the null vector is passed, this function panics.
impl<T: Float, const N: usize, S: Space> From<Vector<T, N, S>> for Dir<T, N, S>
If the null vector is passed, this function panics.
Source§impl<T: Scalar, const C: usize, const R: usize, Src: Space, Dst: Space> Mul<Dir<T, C, Src>> for &Matrix<T, C, R, Src, Dst>
See Matrix::transform.
impl<T: Scalar, const C: usize, const R: usize, Src: Space, Dst: Space> Mul<Dir<T, C, Src>> for &Matrix<T, C, R, Src, Dst>
See Matrix::transform.
impl<T: Scalar, const N: usize, S: Space> Copy for Dir<T, N, S>
impl<T: Scalar + Pod, const N: usize, S: Space> Pod for Dir<T, N, S>
Auto Trait Implementations§
impl<T, const N: usize, S> Freeze for Dir<T, N, S>where
T: Freeze,
impl<T, const N: usize, S> RefUnwindSafe for Dir<T, N, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, const N: usize, S> Send for Dir<T, N, S>
impl<T, const N: usize, S> Sync for Dir<T, N, S>
impl<T, const N: usize, S> Unpin for Dir<T, N, S>
impl<T, const N: usize, S> UnwindSafe for Dir<T, N, S>where
T: UnwindSafe,
S: UnwindSafe,
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.