pub struct Vec3(/* private fields */);Expand description
Color and position values are stored as floats Colors are actually written to memory as bytes (0->255)
Implementations§
Source§impl Vec3
impl Vec3
pub const fn new(x: f64, y: f64, z: f64) -> Self
pub const fn new_with_tuple(tuple: (f64, f64, f64)) -> Self
pub const fn new_with_array(array: [f64; 3]) -> Self
pub const fn splat(value: f64) -> Self
pub fn to_f64_array(&self) -> [f64; 3]
pub fn to_f32_array(&self) -> [f32; 3]
pub const fn x(&self) -> f64
pub const fn y(&self) -> f64
pub const fn z(&self) -> f64
pub const fn r(&self) -> f64
pub const fn g(&self) -> f64
pub const fn b(&self) -> f64
pub fn length(&self) -> f64
pub fn length_squared(&self) -> f64
pub fn dot(a: impl Into<Vec3>, b: impl Into<Vec3>) -> f64
pub fn cross(a: impl Into<Vec3>, b: impl Into<Vec3>) -> Vec3
pub fn normalize(self: Vec3) -> Vec3
Sourcepub fn map_to_color_range(&self) -> Vec3
pub fn map_to_color_range(&self) -> Vec3
from (-1, 1) to (0, 1)
pub fn random_with_range(min: f64, max: f64) -> Self
Sourcepub fn random_point_in_unit_sphere() -> Vec3
pub fn random_point_in_unit_sphere() -> Vec3
INSIDE the unit sphere
Sourcepub fn random_unit_vector() -> Vec3
pub fn random_unit_vector() -> Vec3
along the EDGE of the unit sphere
pub fn is_near_zero(&self) -> bool
Trait Implementations§
Source§impl AddAssign<f64> for Vec3
impl AddAssign<f64> for Vec3
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
Performs the
+= operation. Read moreSource§impl AddAssign for Vec3
impl AddAssign for Vec3
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
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 DivAssign for Vec3
impl DivAssign for Vec3
Source§fn div_assign(&mut self, rhs: Vec3)
fn div_assign(&mut self, rhs: Vec3)
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 MulAssign for Vec3
impl MulAssign for Vec3
Source§fn mul_assign(&mut self, rhs: Vec3)
fn mul_assign(&mut self, rhs: Vec3)
Performs the
*= operation. Read moreSource§impl PartialOrd for Vec3
impl PartialOrd for Vec3
Source§impl SubAssign<f64> for Vec3
impl SubAssign<f64> for Vec3
Source§fn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
Performs the
-= operation. Read moreSource§impl SubAssign for Vec3
impl SubAssign for Vec3
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Vec3
impl StructuralPartialEq for Vec3
Auto Trait Implementations§
impl Freeze for Vec3
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