diff options
Diffstat (limited to 'src/ray.rs')
-rw-r--r-- | src/ray.rs | 21 |
1 files changed, 21 insertions, 0 deletions
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 + } +} |