pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
A three-dimensional vector with double-precision components.
Fields§
§x: f64The x component.
y: f64The y component.
z: f64The z component.
Implementations§
Source§impl Vec3
impl Vec3
Sourcepub fn length_squared(self) -> f64
pub fn length_squared(self) -> f64
Returns the squared Euclidean length.
Sourcepub fn normalized(self) -> Option<Self>
pub fn normalized(self) -> Option<Self>
Returns a unit vector in the same direction, or None if the vector
is zero, too small to normalize reliably, or non-finite.
Sourcepub fn canonicalized(self) -> Self
pub fn canonicalized(self) -> Self
Chooses a deterministic sign by making the largest-magnitude component non-negative.
Sourcepub fn orthonormal_basis(self) -> Option<(Self, Self)>
pub fn orthonormal_basis(self) -> Option<(Self, Self)>
Builds two unit vectors perpendicular to this vector and each other.
Returns None when this vector cannot be normalized.
Trait Implementations§
Source§impl AddAssign for Vec3
impl AddAssign for Vec3
Source§fn add_assign(&mut self, r: Self)
fn add_assign(&mut self, r: Self)
Performs the
+= operation. Read moreimpl Copy for Vec3
Source§impl<'de> Deserialize<'de> for Vec3
impl<'de> Deserialize<'de> for Vec3
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Vec3
Auto Trait Implementations§
impl Freeze for Vec3
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnsafeUnpin for Vec3
impl UnwindSafe for Vec3
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
Mutably borrows from an owned value. Read more