pub struct Vector3<T: Vector3Coordinate> { /* private fields */ }
Expand description
Represents a vector in 3D space.
Implementations§
Source§impl<T: Vector3Coordinate + Float> Vector3<T>where
Standard: Distribution<T>,
impl<T: Vector3Coordinate + Float> Vector3<T>where
Standard: Distribution<T>,
Sourcepub fn fuzzy_equal(&self, target: &Self, epsilon: f64) -> bool
pub fn fuzzy_equal(&self, target: &Self, epsilon: f64) -> bool
Checks if this vector is approximately equal to another vector within a given epsilon.
§Examples
use vec3_rs::Vector3;
let v1 = Vector3::new(0.1, 0.2, 0.3);
let v2 = Vector3::new(0.101, 0.199, 0.299);
let epsilon = 0.01;
let is_approx_equal = v1.fuzzy_equal(&v2, epsilon);
println!("Are v1 and v2 approximately equal? {}", is_approx_equal);
Source§impl<T: Vector3Coordinate> Vector3<T>
impl<T: Vector3Coordinate> Vector3<T>
Sourcepub fn new(x: T, y: T, z: T) -> Self
pub fn new(x: T, y: T, z: T) -> Self
Creates a new Vector3 with the specified coordinates.
§Examples
use vec3_rs::Vector3;
let vector3 = Vector3::new(1.0, 2.0, 3.0);
Sourcepub fn dot(&self, target: &Self) -> T
pub fn dot(&self, target: &Self) -> T
Computes the dot product between this vector and another vector.
Sourcepub fn cross(&self, target: &Self) -> Self
pub fn cross(&self, target: &Self) -> Self
Computes the cross product between this vector and another vector.
Sourcepub fn max(&self, target: &Self) -> Self
pub fn max(&self, target: &Self) -> Self
Computes the component-wise maximum of this vector and another vector.
Sourcepub fn min(&self, target: &Self) -> Self
pub fn min(&self, target: &Self) -> Self
Computes the component-wise minimum of this vector and another vector.
Sourcepub fn angle(&self, target: &Self) -> f64
pub fn angle(&self, target: &Self) -> f64
Computes the angle in radians between this vector and another vector.
Trait Implementations§
Source§impl<T: Vector3Coordinate> Add for Vector3<T>
impl<T: Vector3Coordinate> Add for Vector3<T>
Source§impl<T: Vector3Coordinate> AddAssign for Vector3<T>
impl<T: Vector3Coordinate> AddAssign for Vector3<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl<T: Vector3Coordinate> Display for Vector3<T>
impl<T: Vector3Coordinate> Display for Vector3<T>
Source§impl<T: Vector3Coordinate> Div<T> for Vector3<T>
impl<T: Vector3Coordinate> Div<T> for Vector3<T>
Source§impl<T: Vector3Coordinate> Div for Vector3<T>
impl<T: Vector3Coordinate> Div for Vector3<T>
Source§impl<T: Vector3Coordinate> DivAssign<T> for Vector3<T>
impl<T: Vector3Coordinate> DivAssign<T> for Vector3<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moreSource§impl<T: Vector3Coordinate> DivAssign for Vector3<T>
impl<T: Vector3Coordinate> DivAssign for Vector3<T>
Source§fn div_assign(&mut self, rhs: Vector3<T>)
fn div_assign(&mut self, rhs: Vector3<T>)
Performs the
/=
operation. Read moreSource§impl<T: Vector3Coordinate> Mul<T> for Vector3<T>
impl<T: Vector3Coordinate> Mul<T> for Vector3<T>
Source§impl<T: Vector3Coordinate> Mul for Vector3<T>
impl<T: Vector3Coordinate> Mul for Vector3<T>
Source§impl<T: Vector3Coordinate> MulAssign<T> for Vector3<T>
impl<T: Vector3Coordinate> MulAssign<T> for Vector3<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moreSource§impl<T: Vector3Coordinate> MulAssign for Vector3<T>
impl<T: Vector3Coordinate> MulAssign for Vector3<T>
Source§fn mul_assign(&mut self, rhs: Vector3<T>)
fn mul_assign(&mut self, rhs: Vector3<T>)
Performs the
*=
operation. Read moreSource§impl<T: PartialOrd + Vector3Coordinate> PartialOrd for Vector3<T>
impl<T: PartialOrd + Vector3Coordinate> PartialOrd for Vector3<T>
Source§impl<T: Vector3Coordinate> Sub for Vector3<T>
impl<T: Vector3Coordinate> Sub for Vector3<T>
Source§impl<T: Vector3Coordinate> SubAssign for Vector3<T>
impl<T: Vector3Coordinate> SubAssign for Vector3<T>
Source§fn sub_assign(&mut self, rhs: Vector3<T>)
fn sub_assign(&mut self, rhs: Vector3<T>)
Performs the
-=
operation. Read moreimpl<T: Copy + Vector3Coordinate> Copy for Vector3<T>
impl<T: Vector3Coordinate> StructuralPartialEq for Vector3<T>
Auto Trait Implementations§
impl<T> Freeze for Vector3<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector3<T>where
T: RefUnwindSafe,
impl<T> Send for Vector3<T>where
T: Send,
impl<T> Sync for Vector3<T>where
T: Sync,
impl<T> Unpin for Vector3<T>where
T: Unpin,
impl<T> UnwindSafe for Vector3<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