diff --git a/src/ray.rs b/src/ray.rs index b10d480..cf60b28 100644 --- a/src/ray.rs +++ b/src/ray.rs @@ -1,18 +1,17 @@ -use crate::EPSILON; +use crate::{EPSILON, EPSILON_VECTOR}; -use nalgebra::{Matrix4, Point3, Vector3}; +use nalgebra::{Matrix4, Point3, Unit, Vector3}; pub struct Ray { pub a: Point3, - pub b: Vector3, + pub b: Unit>, } impl Ray { - pub fn new(a: Point3, b: Vector3) -> Ray { - let b = b.normalize(); + pub fn new(a: Point3, b: Unit>) -> Ray { Ray { a, b } } pub fn at_t(&self, t: f32) -> Point3 { - self.a + self.b * t + self.a + self.b.as_ref() * (t + EPSILON) } }