aboutsummaryrefslogtreecommitdiff
path: root/src/ray.rs
blob: 0a4fc3c3f7a37e7aec5b77df74d8db781ee02e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::vec3::{Point3, Vec3};

pub struct Ray {
    pub origin: Point3,
    pub direction: Vec3,
    pub time: f64,
}

impl Ray {
    pub fn new() -> Ray {
        Ray {
            origin: Point3 { x: 0.0, y: 0.0, z: 0.0 },
            direction: Vec3 { x: 0.0, y:0.0, z: 0.0},
            time: 0.0
        }
    }

    pub fn at(&self, t: f64) -> Point3 {
        &self.origin + t * &self.direction
    }
}