aboutsummaryrefslogtreecommitdiff
path: root/src/core/vector3.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-06 23:43:06 +0100
committerJulian T <julian@jtle.dk>2021-02-06 23:43:06 +0100
commitb64c7e972c52b7d015d661866f0cf902370343e5 (patch)
tree8d3dc9a8ae6b491b9f8f639f2d0bad6387d59069 /src/core/vector3.rs
parent0d5e6bd9363d5ed5c4f28174819fc0f5fd9aa586 (diff)
Implement pathtracing
Diffstat (limited to 'src/core/vector3.rs')
-rw-r--r--src/core/vector3.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/vector3.rs b/src/core/vector3.rs
index 10de647..ef067aa 100644
--- a/src/core/vector3.rs
+++ b/src/core/vector3.rs
@@ -50,6 +50,18 @@ impl<T: Number> Add for Vector3<T> {
}
}
+impl<T: Number> Add<T> for Vector3<T> {
+ type Output = Self;
+
+ fn add(self, op: T) -> Self::Output {
+ Self::new_xyz(
+ self.x + op,
+ self.y + op,
+ self.z + op,
+ )
+ }
+}
+
impl<T: Number> Mul<T> for Vector3<T> {
type Output = Self;
fn mul(self, op: T) -> Self::Output {
@@ -114,6 +126,7 @@ impl Vector3f {
/// assert!(v.x == 1.0);
/// ```
pub fn norm_in(&mut self) {
+ // TODO Experiment with checking for normality with len_squared
let len = self.len();
if len == 0.0 {
*self = Self::new(0.0);