#[repr(C)]pub struct Vector3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
Expand description
A vector in 3D space.
Fields§
§x: f32
§y: f32
§z: f32
Implementations§
Source§impl Vector3
impl Vector3
Sourcepub const fn new(x: f32, y: f32, z: f32) -> Self
pub const fn new(x: f32, y: f32, z: f32) -> Self
Construct new a vector from individual coordinates
Sourcepub const fn from_scalar(s: f32) -> Self
pub const fn from_scalar(s: f32) -> Self
Construct new a vector where each coordinate is the same
Sourcepub fn lerp(&self, rhs: Self, factor: f32) -> Self
pub fn lerp(&self, rhs: Self, factor: f32) -> Self
Linear interpolation between this vector and another
Sourcepub fn min(&self, rhs: Self) -> Self
pub fn min(&self, rhs: Self) -> Self
Compute the element-wise minimum of this vector and another
Sourcepub fn max(&self, rhs: Self) -> Self
pub fn max(&self, rhs: Self) -> Self
Compute the element-wise maximum of this vector and another
Sourcepub fn magnitude_squared(&self) -> f32
pub fn magnitude_squared(&self) -> f32
The length of this vector squared. Note that this avoids an expensive square root.
Sourcepub fn magnitude(&self) -> f32
pub fn magnitude(&self) -> f32
The length of this vector. Note that this involves an expensive square root.
Sourcepub fn normalized(&self) -> Self
pub fn normalized(&self) -> Self
Normalize this vector to unit length. Note that this involves an expensive square root.
pub fn as_slice(&self) -> &[f32]
Trait Implementations§
Source§impl AddAssign<Vector3> for Point
impl AddAssign<Vector3> for Point
Source§fn add_assign(&mut self, rhs: Vector3)
fn add_assign(&mut self, rhs: Vector3)
Performs the
+=
operation. Read moreSource§impl AddAssign<f32> for Vector3
impl AddAssign<f32> for Vector3
Source§fn add_assign(&mut self, t: f32)
fn add_assign(&mut self, t: f32)
Performs the
+=
operation. Read moreSource§impl AddAssign for Vector3
impl AddAssign for Vector3
Source§fn add_assign(&mut self, rhs: Vector3)
fn add_assign(&mut self, rhs: Vector3)
Performs the
+=
operation. Read moreSource§impl DivAssign<f32> for Vector3
impl DivAssign<f32> for Vector3
Source§fn div_assign(&mut self, t: f32)
fn div_assign(&mut self, t: f32)
Performs the
/=
operation. Read moreSource§impl DivAssign for Vector3
impl DivAssign for Vector3
Source§fn div_assign(&mut self, rhs: Vector3)
fn div_assign(&mut self, rhs: Vector3)
Performs the
/=
operation. Read moreSource§impl MulAssign<f32> for Vector3
impl MulAssign<f32> for Vector3
Source§fn mul_assign(&mut self, t: f32)
fn mul_assign(&mut self, t: f32)
Performs the
*=
operation. Read moreSource§impl MulAssign for Vector3
impl MulAssign for Vector3
Source§fn mul_assign(&mut self, rhs: Vector3)
fn mul_assign(&mut self, rhs: Vector3)
Performs the
*=
operation. Read moreSource§impl NearlyEqual for &Vector3
impl NearlyEqual for &Vector3
fn nearly_equals(self, rhs: Self) -> bool
Source§impl SubAssign<Vector3> for Point
impl SubAssign<Vector3> for Point
Source§fn sub_assign(&mut self, rhs: Vector3)
fn sub_assign(&mut self, rhs: Vector3)
Performs the
-=
operation. Read moreSource§impl SubAssign<f32> for Vector3
impl SubAssign<f32> for Vector3
Source§fn sub_assign(&mut self, t: f32)
fn sub_assign(&mut self, t: f32)
Performs the
-=
operation. Read moreSource§impl SubAssign for Vector3
impl SubAssign for Vector3
Source§fn sub_assign(&mut self, rhs: Vector3)
fn sub_assign(&mut self, rhs: Vector3)
Performs the
-=
operation. Read moreimpl Copy for Vector3
impl StructuralPartialEq for Vector3
Auto Trait Implementations§
impl Freeze for Vector3
impl RefUnwindSafe for Vector3
impl Send for Vector3
impl Sync for Vector3
impl Unpin for Vector3
impl UnwindSafe for Vector3
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