use nalgebra::Vector3; /// A normalized parametric Ray of the form (origin + direction * time) /// /// That means at any time t: f64, the point represented by origin + direction * /// time occurs on the ray. #[derive(Debug)] pub struct Ray { pub origin: Vector3, pub direction: Vector3, } impl Ray { /// Construct a ray from endpoints pub fn from_endpoints(start: Vector3, end: Vector3) -> Self { let delta = (end - start).normalize(); Ray { origin: start, direction: delta, } } /// Evaluate the ray at a certain point in time, yielding a point pub fn eval(&self, time: f64) -> Vector3 { self.origin + self.direction * time } }