pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
A 3D vector for position, velocity, and other spatial quantities.
Fields§
§x: f64X component
y: f64Y component
z: f64Z component
Implementations§
Source§impl Vector3
impl Vector3
Sourcepub fn from_array(arr: [f64; 3]) -> Self
pub fn from_array(arr: [f64; 3]) -> Self
Create a Vector3 from an array.
Sourcepub fn from_tuple(t: (f64, f64, f64)) -> Self
pub fn from_tuple(t: (f64, f64, f64)) -> Self
Create a Vector3 from a tuple.
Sourcepub fn magnitude_squared(&self) -> f64
pub fn magnitude_squared(&self) -> f64
Compute the squared magnitude (avoids sqrt).
Sourcepub fn normalize(&self) -> Self
pub fn normalize(&self) -> Self
Normalize the vector to unit length. Returns a zero vector if the magnitude is zero.
Sourcepub fn rotate_around_axis(&self, axis: &Vector3, angle: f64) -> Self
pub fn rotate_around_axis(&self, axis: &Vector3, angle: f64) -> Self
Rotate the vector around an arbitrary axis by an angle (radians).
Trait Implementations§
impl 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