summaryrefslogtreecommitdiff
path: root/racer-tracer/src/ray.rs
blob: 1325cc22f3acd516f8ebb793746cca1a2f98350d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::vec3::Vec3;

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

impl Ray {
    pub fn new(origin: Vec3, direction: Vec3) -> Ray {
        Ray { origin, direction }
    }

    pub fn origin(&self) -> &Vec3 {
        &self.origin
    }

    pub fn direction(&self) -> &Vec3 {
        &self.direction
    }

    pub fn at(&self, go_length: f64) -> Vec3 {
        self.origin.clone() + go_length * self.direction.clone()
    }
}