#[repr(C)]pub struct Vec3 {
pub x: Float,
pub y: Float,
pub z: Float,
}Expand description
A 3D vector.
Fields§
§x: FloatX component.
y: FloatY component.
z: FloatZ component.
Implementations§
Source§impl Vec3
impl Vec3
Sourcepub const fn splat(value: Float) -> Self
pub const fn splat(value: Float) -> Self
Creates a vector with all components set to the same value.
Sourcepub const fn from_array(arr: [Float; 3]) -> Self
pub const fn from_array(arr: [Float; 3]) -> Self
Creates a vector from an array.
Sourcepub const fn from_vec2(v: Vec2, z: Float) -> Self
pub const fn from_vec2(v: Vec2, z: Float) -> Self
Extends to Vec3 from Vec2 with a z component.
Sourcepub fn length_squared(self) -> Float
pub fn length_squared(self) -> Float
Computes the squared length.
Sourcepub fn try_normalize(self) -> Option<Self>
pub fn try_normalize(self) -> Option<Self>
Returns a normalized vector, or None if length is near zero.
Sourcepub fn distance_squared(self, other: Self) -> Float
pub fn distance_squared(self, other: Self) -> Float
Computes the squared distance to another vector.
Sourcepub fn angle_between(self, other: Self) -> Float
pub fn angle_between(self, other: Self) -> Float
Computes the angle in radians between two vectors.
Sourcepub fn approx_eq(self, other: Self) -> bool
pub fn approx_eq(self, other: Self) -> bool
Checks if this vector is approximately equal to another.
Trait Implementations§
Source§impl AddAssign for Vec3
impl AddAssign for Vec3
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl DivAssign<f32> for Vec3
impl DivAssign<f32> for Vec3
Source§fn div_assign(&mut self, scalar: Float)
fn div_assign(&mut self, scalar: Float)
Performs the
/= operation. Read moreSource§impl MulAssign<f32> for Vec3
impl MulAssign<f32> for Vec3
Source§fn mul_assign(&mut self, scalar: Float)
fn mul_assign(&mut self, scalar: Float)
Performs the
*= operation. Read moreSource§impl SubAssign for Vec3
impl SubAssign for Vec3
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreimpl Copy for Vec3
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 UnwindSafe for Vec3
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more