Add simple ray module.

This commit is contained in:
Bill Thiede 2018-09-08 19:58:24 -07:00
parent e1199611f0
commit b8861b7f8d
2 changed files with 23 additions and 0 deletions

View File

@ -1 +1,2 @@
pub mod ray;
pub mod vec3;

22
rtiow/src/ray.rs Normal file
View File

@ -0,0 +1,22 @@
use vec3::Vec3;
#[derive(Default)]
pub struct Ray {
a: Vec3,
b: Vec3,
}
impl Ray {
pub fn new(a: Vec3, b: Vec3) -> Ray {
Ray { a, b }
}
pub fn origin(self) -> Vec3 {
self.a
}
pub fn direction(self) -> Vec3 {
self.b
}
pub fn point_at_parameter(self, t: f32) -> Vec3 {
self.a + self.b * t
}
}