From 78ddaff5855bf8446adef9e18eb0d7b7ddcee52a Mon Sep 17 00:00:00 2001 From: lamp Date: Sun, 5 Mar 2023 21:45:56 +0000 Subject: init --- src/ray.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/ray.rs (limited to 'src/ray.rs') diff --git a/src/ray.rs b/src/ray.rs new file mode 100644 index 0000000..0a4fc3c --- /dev/null +++ b/src/ray.rs @@ -0,0 +1,21 @@ +use crate::vec3::{Point3, Vec3}; + +pub struct Ray { + pub origin: Point3, + pub direction: Vec3, + pub time: f64, +} + +impl Ray { + pub fn new() -> Ray { + Ray { + origin: Point3 { x: 0.0, y: 0.0, z: 0.0 }, + direction: Vec3 { x: 0.0, y:0.0, z: 0.0}, + time: 0.0 + } + } + + pub fn at(&self, t: f64) -> Point3 { + &self.origin + t * &self.direction + } +} -- cgit v1.2.3