Struct bevy_math::primitives::Direction3d
source · pub struct Direction3d(/* private fields */);
Expand description
A normalized vector pointing in a direction in 3D space
Implementations§
source§impl Direction3d
impl Direction3d
sourcepub fn new(value: Vec3) -> Result<Self, InvalidDirectionError>
pub fn new(value: Vec3) -> Result<Self, InvalidDirectionError>
Create a direction from a finite, nonzero Vec3
.
Returns Err(InvalidDirectionError)
if the length
of the given vector is zero (or very close to zero), infinite, or NaN
.
sourcepub fn new_unchecked(value: Vec3) -> Self
pub fn new_unchecked(value: Vec3) -> Self
Create a Direction3d
from a Vec3
that is already normalized.
Warning
value
must be normalized, i.e it’s length must be 1.0
.
sourcepub fn new_and_length(value: Vec3) -> Result<(Self, f32), InvalidDirectionError>
pub fn new_and_length(value: Vec3) -> Result<(Self, f32), InvalidDirectionError>
Create a direction from a finite, nonzero Vec3
, also returning its original length.
Returns Err(InvalidDirectionError)
if the length
of the given vector is zero (or very close to zero), infinite, or NaN
.
sourcepub fn from_xyz(x: f32, y: f32, z: f32) -> Result<Self, InvalidDirectionError>
pub fn from_xyz(x: f32, y: f32, z: f32) -> Result<Self, InvalidDirectionError>
Create a direction from its x
, y
, and z
components.
Returns Err(InvalidDirectionError)
if the length
of the vector formed by the components is zero (or very close to zero), infinite, or NaN
.
Methods from Deref<Target = Vec3>§
pub const ZERO: Vec3 = _
pub const ONE: Vec3 = _
pub const NEG_ONE: Vec3 = _
pub const MIN: Vec3 = _
pub const MAX: Vec3 = _
pub const NAN: Vec3 = _
pub const INFINITY: Vec3 = _
pub const NEG_INFINITY: Vec3 = _
pub const X: Vec3 = _
pub const Y: Vec3 = _
pub const Z: Vec3 = _
pub const NEG_X: Vec3 = _
pub const NEG_Y: Vec3 = _
pub const NEG_Z: Vec3 = _
pub const AXES: [Vec3; 3] = _
sourcepub fn any_orthogonal_vector(&self) -> Vec3
pub fn any_orthogonal_vector(&self) -> Vec3
Returns some vector that is orthogonal to the given one.
The input vector must be finite and non-zero.
The output vector is not necessarily unit length. For that use
Self::any_orthonormal_vector()
instead.
sourcepub fn any_orthonormal_vector(&self) -> Vec3
pub fn any_orthonormal_vector(&self) -> Vec3
Returns any unit vector that is orthogonal to the given one.
The input vector must be unit length.
Panics
Will panic if self
is not normalized when glam_assert
is enabled.
sourcepub fn any_orthonormal_pair(&self) -> (Vec3, Vec3)
pub fn any_orthonormal_pair(&self) -> (Vec3, Vec3)
Given a unit vector return two other vectors that together form an orthonormal basis. That is, all three vectors are orthogonal to each other and are normalized.
Panics
Will panic if self
is not normalized when glam_assert
is enabled.
sourcepub fn as_i16vec3(&self) -> I16Vec3
pub fn as_i16vec3(&self) -> I16Vec3
Casts all elements of self
to i16
.
sourcepub fn as_u16vec3(&self) -> U16Vec3
pub fn as_u16vec3(&self) -> U16Vec3
Casts all elements of self
to u16
.
sourcepub fn as_i64vec3(&self) -> I64Vec3
pub fn as_i64vec3(&self) -> I64Vec3
Casts all elements of self
to i64
.
sourcepub fn as_u64vec3(&self) -> U64Vec3
pub fn as_u64vec3(&self) -> U64Vec3
Casts all elements of self
to u64
.
Trait Implementations§
source§impl Clone for Direction3d
impl Clone for Direction3d
source§fn clone(&self) -> Direction3d
fn clone(&self) -> Direction3d
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Direction3d
impl Debug for Direction3d
source§impl Deref for Direction3d
impl Deref for Direction3d
source§impl<'de> Deserialize<'de> for Direction3d
impl<'de> Deserialize<'de> for Direction3d
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Direction3d> for Vec3
impl From<Direction3d> for Vec3
source§fn from(value: Direction3d) -> Self
fn from(value: Direction3d) -> Self
source§impl Mul<Direction3d> for Quat
impl Mul<Direction3d> for Quat
source§fn mul(self, direction: Direction3d) -> Self::Output
fn mul(self, direction: Direction3d) -> Self::Output
Rotates the Direction3d
using a Quat
.
§type Output = Direction3d
type Output = Direction3d
*
operator.source§impl Mul<f32> for Direction3d
impl Mul<f32> for Direction3d
source§impl Neg for Direction3d
impl Neg for Direction3d
source§impl PartialEq for Direction3d
impl PartialEq for Direction3d
source§fn eq(&self, other: &Direction3d) -> bool
fn eq(&self, other: &Direction3d) -> bool
self
and other
values to be equal, and is used
by ==
.