[][src]Struct raytracer::Ray

pub struct Ray {
    pub origin: Vec3,
    pub direction: Vec3,
}

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_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

impl Send for Ray

impl Sync for Ray

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.