pub struct Vector3D { /* private fields */ }Expand description
A 3D vector with x, y, and z components represented as f64.
Implementations§
Source§impl Vector3D
Implements methods and operator overloading for Vector3D.
impl Vector3D
Implements methods and operator overloading for Vector3D.
Sourcepub fn forward() -> Vector3D
pub fn forward() -> Vector3D
Returns the unit vector pointing forward (0.0, 0.0, -1.0).
In a right-handed coordinate system where -z is forward.
§Returns
Vector3D- The forward unit vector.
Sourcepub fn magnitude_squared(&self) -> f64
pub fn magnitude_squared(&self) -> f64
Returns the squared magnitude of the vector.
Avoids a square root, making it faster for comparison-only use cases.
§Returns
f64- The squared magnitude of the vector.
Sourcepub fn normalized(&self) -> Vector3D
pub fn normalized(&self) -> Vector3D
Returns a normalized (unit length) copy of this vector.
Returns the zero vector if the magnitude is zero.
§Returns
Vector3D- The normalized vector.
Sourcepub fn distance_to(&self, other: Vector3D) -> f64
pub fn distance_to(&self, other: Vector3D) -> f64
Sourcepub fn distance_squared_to(&self, other: Vector3D) -> f64
pub fn distance_squared_to(&self, other: Vector3D) -> f64
Sourcepub fn direction_to(&self, other: Vector3D) -> Vector3D
pub fn direction_to(&self, other: Vector3D) -> Vector3D
Sourcepub fn rotated_by(&self, quaternion: Quaternion) -> Vector3D
pub fn rotated_by(&self, quaternion: Quaternion) -> Vector3D
Source§impl Vector3D
impl Vector3D
pub fn get_x(&self) -> f64
pub fn get_mut_x(&mut self) -> &mut f64
pub fn set_x(&mut self, val: f64) -> &mut Self
pub fn get_y(&self) -> f64
pub fn get_mut_y(&mut self) -> &mut f64
pub fn set_y(&mut self, val: f64) -> &mut Self
pub fn get_z(&self) -> f64
pub fn get_mut_z(&mut self) -> &mut f64
pub fn set_z(&mut self, val: f64) -> &mut Self
Trait Implementations§
Source§impl AddAssign for Vector3D
Implements in-place vector addition.
impl AddAssign for Vector3D
Implements in-place vector addition.
Source§fn add_assign(&mut self, other: Vector3D)
fn add_assign(&mut self, other: Vector3D)
+= operation. Read moreimpl Copy for Vector3D
Source§impl Interpolable for Vector3D
Implements Interpolable for Vector3D.
impl Interpolable for Vector3D
Implements Interpolable for Vector3D.
Source§impl MulAssign<f64> for Vector3D
Implements in-place scalar multiplication.
impl MulAssign<f64> for Vector3D
Implements in-place scalar multiplication.
Source§fn mul_assign(&mut self, scalar: f64)
fn mul_assign(&mut self, scalar: f64)
*= operation. Read moreSource§impl PartialOrd for Vector3D
impl PartialOrd for Vector3D
impl StructuralPartialEq for Vector3D
Source§impl SubAssign for Vector3D
Implements in-place vector subtraction.
impl SubAssign for Vector3D
Implements in-place vector subtraction.
Source§fn sub_assign(&mut self, other: Vector3D)
fn sub_assign(&mut self, other: Vector3D)
-= operation. Read moreSource§impl Vector for Vector3D
Implements the Vector trait for Vector3D, forwarding every method to
the inherent implementation on the struct.
impl Vector for Vector3D
Implements the Vector trait for Vector3D, forwarding every method to
the inherent implementation on the struct.
Vector3D also offers 3D-specific operations that are not part of the
trait surface: cross (returning Vector3D), direction_to,
distance_to, scale, and normalize. These remain inherent.