From b64c7e972c52b7d015d661866f0cf902370343e5 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 6 Feb 2021 23:43:06 +0100 Subject: Implement pathtracing --- src/core/ray.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/core/ray.rs') diff --git a/src/core/ray.rs b/src/core/ray.rs index f5517ce..c944184 100644 --- a/src/core/ray.rs +++ b/src/core/ray.rs @@ -8,6 +8,14 @@ pub struct Ray { } impl Ray { + pub fn new_to(origin: Vector3f, target: Vector3f) -> Ray { + let dir = (target - origin).norm(); + Ray { + origin, + direction: dir + } + } + pub fn at(&self, t: Float) -> Vector3f { self.origin + self.direction * t } -- cgit v1.2.3