aboutsummaryrefslogtreecommitdiff
path: root/src/ray.rs
diff options
context:
space:
mode:
authorlamp2023-03-05 21:45:56 +0000
committerlamp2023-03-05 21:45:56 +0000
commit78ddaff5855bf8446adef9e18eb0d7b7ddcee52a (patch)
tree0d0e93cfa28751a2f96518eeb231cf715958e1fa /src/ray.rs
init
Diffstat (limited to 'src/ray.rs')
-rw-r--r--src/ray.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ray.rs b/src/ray.rs
new file mode 100644
index 0000000..0a4fc3c
--- /dev/null
+++ b/src/ray.rs
@@ -0,0 +1,21 @@
+use crate::vec3::{Point3, Vec3};
+
+pub struct Ray {
+ pub origin: Point3,
+ pub direction: Vec3,
+ pub time: f64,
+}
+
+impl Ray {
+ pub fn new() -> Ray {
+ Ray {
+ origin: Point3 { x: 0.0, y: 0.0, z: 0.0 },
+ direction: Vec3 { x: 0.0, y:0.0, z: 0.0},
+ time: 0.0
+ }
+ }
+
+ pub fn at(&self, t: f64) -> Point3 {
+ &self.origin + t * &self.direction
+ }
+}