diff --git a/rtiow/src/lib.rs b/rtiow/src/lib.rs index 9b789be..1d07923 100644 --- a/rtiow/src/lib.rs +++ b/rtiow/src/lib.rs @@ -1 +1,2 @@ +pub mod ray; pub mod vec3; diff --git a/rtiow/src/ray.rs b/rtiow/src/ray.rs new file mode 100644 index 0000000..a9a67c0 --- /dev/null +++ b/rtiow/src/ray.rs @@ -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 + } +}