pub struct Vector3d<T: Float> {
pub x: T,
pub y: T,
pub z: T,
}Expand description
Fields§
§x: TX component.
y: TY component.
z: TZ component.
Implementations§
Trait Implementations§
impl<T: Copy + Float> Copy for Vector3d<T>
Source§impl<T: PartialEq + Float> PartialEq for Vector3d<T>
impl<T: PartialEq + Float> PartialEq for Vector3d<T>
impl<T: Float> StructuralPartialEq for Vector3d<T>
Source§impl<T> VectorOps<T> for Vector3d<T>
impl<T> VectorOps<T> for Vector3d<T>
Source§fn dot(&self, other: &Self) -> Result<T, VectorErr>
fn dot(&self, other: &Self) -> Result<T, VectorErr>
Computes the dot product of two vectors.
§Examples
use mathrc::{Vector3d, VectorOps};
let a = Vector3d::new(1.0, 2.0, 3.0);
let b = Vector3d::new(4.0, 5.0, 6.0);
assert_eq!(a.dot(&b).unwrap(), 32.0);Source§fn magnitude(&self) -> T
fn magnitude(&self) -> T
Returns the Euclidean magnitude of the vector.
§Examples
use mathrc::{Vector3d, VectorOps};
let v = Vector3d::new(1.0, 2.0, 2.0);
assert_eq!(v.magnitude(), 3.0);Source§fn normalize(&self) -> Result<Self, VectorErr>
fn normalize(&self) -> Result<Self, VectorErr>
Returns a normalized vector.
§Errors
Returns VectorErr::ZeroVector if the vector magnitude is zero.
§Examples
use mathrc::{Vector3d, VectorOps};
let v: Vector3d<f64> = Vector3d::new(3.0, 4.0, 0.0);
let n: Vector3d<f64> = v.normalize().unwrap();
assert!((n.magnitude() - 1.0).abs() < 1e-10);Auto Trait Implementations§
impl<T> Freeze for Vector3d<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector3d<T>where
T: RefUnwindSafe,
impl<T> Send for Vector3d<T>where
T: Send,
impl<T> Sync for Vector3d<T>where
T: Sync,
impl<T> Unpin for Vector3d<T>where
T: Unpin,
impl<T> UnsafeUnpin for Vector3d<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Vector3d<T>where
T: UnwindSafe,
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