From 928b4191bf5a0d27da6d680ccaade7f94860359e Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Fri, 6 Jan 2023 22:59:27 +0100 Subject: =?UTF-8?q?=E2=98=81=20Add=20sky?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- racer-tracer/src/ray.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 racer-tracer/src/ray.rs (limited to 'racer-tracer/src/ray.rs') diff --git a/racer-tracer/src/ray.rs b/racer-tracer/src/ray.rs new file mode 100644 index 0000000..1325cc2 --- /dev/null +++ b/racer-tracer/src/ray.rs @@ -0,0 +1,24 @@ +use crate::vec3::Vec3; + +pub struct Ray { + origin: Vec3, + direction: Vec3, +} + +impl Ray { + pub fn new(origin: Vec3, direction: Vec3) -> Ray { + Ray { origin, direction } + } + + pub fn origin(&self) -> &Vec3 { + &self.origin + } + + pub fn direction(&self) -> &Vec3 { + &self.direction + } + + pub fn at(&self, go_length: f64) -> Vec3 { + self.origin.clone() + go_length * self.direction.clone() + } +} -- cgit v1.2.3