diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/bound3.rs | 8 | ||||
-rw-r--r-- | src/core/vector3.rs | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/core/bound3.rs b/src/core/bound3.rs index ce6bb09..8c467c0 100644 --- a/src/core/bound3.rs +++ b/src/core/bound3.rs @@ -64,6 +64,13 @@ impl<T: Number> Bound3<T> { let diag = self.max - self.min; diag.x * diag.y * diag.z } + + pub fn offset(&self, offset: Vector3<T>) -> Self { + Self { + min: self.min + offset, + max: self.max + offset, + } + } } impl Bound3f { @@ -86,7 +93,6 @@ impl Bound3f { /// assert!(!b.intersect(&r3, 0.0, INFTY)); /// ``` pub fn intersect(&self, ray: &Ray, t_min: Float, t_max: Float) -> bool { - println!("BIN: {} -> {}", self.min, self.max); // Method stolen from Ray tracing the next week. // They mention its from pixar for i in 0..3 { diff --git a/src/core/vector3.rs b/src/core/vector3.rs index 1cc6f60..9ba0191 100644 --- a/src/core/vector3.rs +++ b/src/core/vector3.rs @@ -2,7 +2,7 @@ //! //! Also add more 3d math things needed for shading and 3d calculations. use crate::{Float, Number, NEAR_ZERO}; -use std::ops::{Mul, Sub, Add, DivAssign, Neg, AddAssign, Index}; +use std::ops::{Mul, Sub, Add, Div, DivAssign, Neg, AddAssign, Index}; use std::fmt; #[derive(Clone, Copy)] @@ -73,6 +73,17 @@ impl<T: Number> Mul<T> for Vector3<T> { } } +impl<T: Number> Div<T> for Vector3<T> { + type Output = Self; + fn div(self, op: T) -> Self::Output { + Self::Output::new_xyz( + self.x / op, + self.y / op, + self.z / op, + ) + } +} + impl<T: Number> Neg for Vector3<T> { type Output = Self; |