Struct crystal_ball::math::Vec3
source · pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
Expand description
A 3-dimensional vector.
Fields§
§x: f64
§y: f64
§z: f64
Implementations§
source§impl Vec3
impl Vec3
pub const X: Vec3 = _
pub const Y: Vec3 = _
pub const Z: Vec3 = _
pub const ZERO: Vec3 = _
sourcepub fn random(rng: &mut TlsWyRand, min: f64, max: f64) -> Self
pub fn random(rng: &mut TlsWyRand, min: f64, max: f64) -> Self
Generate a Vec3
where each component is a uniform random number between min
and max
.
sourcepub fn random_unit_vector(rng: &mut TlsWyRand) -> Self
pub fn random_unit_vector(rng: &mut TlsWyRand) -> Self
Generate a random Vec3
on the surface of the unit sphere
with uniform (i.e. isotropic) distribution.
sourcepub fn random_in_unit_sphere(rng: &mut TlsWyRand) -> Self
pub fn random_in_unit_sphere(rng: &mut TlsWyRand) -> Self
Generate a random Vec3
inside the unit sphere with uniform distribution.
sourcepub fn refract(
self,
normal: Vec3,
n1: f64,
n2: f64,
rng: &mut TlsWyRand
) -> Self
pub fn refract( self, normal: Vec3, n1: f64, n2: f64, rng: &mut TlsWyRand ) -> Self
Refract the self
with respect to the given normal using n1 and n2 as the indices of refraction.
sourcepub fn magnitude_squared(&self) -> f64
pub fn magnitude_squared(&self) -> f64
Calculate the square of the vector’s magnitude (length).
Trait Implementations§
source§impl AddAssign<Vec3> for Point3
impl AddAssign<Vec3> for Point3
source§fn add_assign(&mut self, rhs: Vec3)
fn add_assign(&mut self, rhs: Vec3)
Performs the
+=
operation. Read moresource§impl AddAssign for Vec3
impl AddAssign for Vec3
source§fn add_assign(&mut self, rhs: Vec3)
fn add_assign(&mut self, rhs: Vec3)
Performs the
+=
operation. Read moresource§impl DivAssign<f64> for Vec3
impl DivAssign<f64> for Vec3
source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
Performs the
/=
operation. Read moresource§impl MulAssign<f64> for Vec3
impl MulAssign<f64> for Vec3
source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*=
operation. Read moresource§impl PartialEq for Vec3
impl PartialEq for Vec3
source§impl SubAssign<Vec3> for Point3
impl SubAssign<Vec3> for Point3
source§fn sub_assign(&mut self, rhs: Vec3)
fn sub_assign(&mut self, rhs: Vec3)
Performs the
-=
operation. Read moresource§impl SubAssign for Vec3
impl SubAssign for Vec3
source§fn sub_assign(&mut self, rhs: Vec3)
fn sub_assign(&mut self, rhs: Vec3)
Performs the
-=
operation. Read moreimpl Copy for Vec3
impl StructuralPartialEq for Vec3
Auto Trait Implementations§
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
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
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.