diff options
author | Julian T <julian@jtle.dk> | 2021-02-06 23:43:06 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-06 23:43:06 +0100 |
commit | b64c7e972c52b7d015d661866f0cf902370343e5 (patch) | |
tree | 8d3dc9a8ae6b491b9f8f639f2d0bad6387d59069 /src/core/ray.rs | |
parent | 0d5e6bd9363d5ed5c4f28174819fc0f5fd9aa586 (diff) |
Implement pathtracing
Diffstat (limited to 'src/core/ray.rs')
-rw-r--r-- | src/core/ray.rs | 8 |
1 files changed, 8 insertions, 0 deletions
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 } |