aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ray.rs5
-rw-r--r--src/core/spectrum.rs1
2 files changed, 6 insertions, 0 deletions
diff --git a/src/core/ray.rs b/src/core/ray.rs
index 0517e50..19d3cf1 100644
--- a/src/core/ray.rs
+++ b/src/core/ray.rs
@@ -2,8 +2,12 @@
use crate::core::Vector3f;
use crate::Float;
+/// A ray that is sent into the world.
+/// This is the main type used for testing intersections.
pub struct Ray {
+ /// Origin of the ray
pub origin: Vector3f,
+ /// Direction is assumed to be a unit vector.
pub direction: Vector3f,
}
@@ -23,6 +27,7 @@ impl Ray {
}
}
+ /// Resolve a point on the ray at time t
pub fn at(&self, t: Float) -> Vector3f {
self.origin + self.direction * t
}
diff --git a/src/core/spectrum.rs b/src/core/spectrum.rs
index bea056e..ed3505b 100644
--- a/src/core/spectrum.rs
+++ b/src/core/spectrum.rs
@@ -12,6 +12,7 @@ pub struct Spectrum {
impl Spectrum {
pub const ZERO: Self = Spectrum { c: [0.0; 3] };
+ pub const WHITE: Self = Spectrum { c: [1.0; 3] };
pub fn new_rgb(r: Float, g: Float, b: Float) -> Spectrum {
Spectrum { c: [r, g, b] }