pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
A three-dimensional vector.
§Examples
use use_vector::Vector3;
let vector = Vector3::new(2.0, 3.0, 6.0);
assert_eq!(vector.magnitude(), 7.0);Fields§
§x: f64The x component.
y: f64The y component.
z: f64The z component.
Implementations§
Source§impl Vector3
impl Vector3
Sourcepub fn magnitude_squared(self) -> f64
pub fn magnitude_squared(self) -> f64
Returns the squared Euclidean magnitude.
Sourcepub fn normalize(self) -> Option<Self>
pub fn normalize(self) -> Option<Self>
Returns a normalized vector when the magnitude is finite and non-zero.
Returns None for zero vectors or vectors with non-finite magnitude.
Sourcepub fn distance_squared(self, other: Self) -> f64
pub fn distance_squared(self, other: Self) -> f64
Returns the squared Euclidean distance to other.
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 UnsafeUnpin 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