diff options
author | Julian T <julian@jtle.dk> | 2021-07-31 14:02:52 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-07-31 14:02:52 +0200 |
commit | cee9bcf4a2c8ffbfe6487f7886b2247eaba1c92c (patch) | |
tree | 7fd405d9a3f6351d6341706fba50a8616d6c3a84 /src/core | |
parent | 55044e56304c8484b8ff52f362ab1c66c9c5ca93 (diff) |
Better documentation and cleanup
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ray.rs | 5 | ||||
-rw-r--r-- | src/core/spectrum.rs | 1 |
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] } |