diff options
| author | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-06 22:59:27 +0100 |
|---|---|---|
| committer | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-06 22:59:27 +0100 |
| commit | 928b4191bf5a0d27da6d680ccaade7f94860359e (patch) | |
| tree | b2c1e301c1c5c7b5d8cb9a92cc9d4c925e54a7b9 /racer-tracer/src/ray.rs | |
| parent | 372bc5b09c50cf2440e8f7762dd260cefd7bba7f (diff) | |
| download | racer-tracer-928b4191bf5a0d27da6d680ccaade7f94860359e.tar.gz racer-tracer-928b4191bf5a0d27da6d680ccaade7f94860359e.tar.xz racer-tracer-928b4191bf5a0d27da6d680ccaade7f94860359e.zip | |
☁ Add sky
Diffstat (limited to 'racer-tracer/src/ray.rs')
| -rw-r--r-- | racer-tracer/src/ray.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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() + } +} |
