summaryrefslogtreecommitdiff
path: root/racer-tracer/src/ray.rs
diff options
context:
space:
mode:
Diffstat (limited to 'racer-tracer/src/ray.rs')
-rw-r--r--racer-tracer/src/ray.rs24
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()
+ }
+}