[−][src]Struct raytracer::Ray
This struct represents a mathematical ray.
Fields
origin: Vec3
Starting point of a ray.
direction: Vec3
Direction of a ray.
In mathematics, ray does not have a length, but this vector isn't guaranteed to be an unit vector. It is useful when distance between origin and point that ray intersects is needed.
Methods
impl Ray
[src]
pub fn new(origin: Vec3, direction: Vec3) -> Ray
[src]
Ray constructor.
Examples
let r = Ray::new(vec3!(0.0), vec3!(5.0)); assert_eq!(r.origin, vec3!(0.0)); assert_eq!(r.direction, vec3!(5.0));
pub fn at(self, t: f32) -> Vec3
[src]
Returns a point between origin and direction.
When t = 0, returns Ray.origin
, when t = 1, returns Ray.direction
.
Examples
let origin = vec3!(0.0); let direction = vec3!(10.0); let r = ray!(origin, direction); assert_eq!(r.at(0.0), origin); assert_eq!(r.at(0.75), vec3!(7.5)); assert_eq!(r.at(1.0), direction);
Trait Implementations
impl Clone for Ray
[src]
fn clone(&self) -> Ray
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Ray
[src]
impl PartialEq<Ray> for Ray
[src]
impl Debug for Ray
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,