aboutsummaryrefslogtreecommitdiff
path: root/src/core/vector3.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-07 14:25:06 +0100
committerJulian T <julian@jtle.dk>2021-02-07 14:26:20 +0100
commit33e747fa1c0957546c10e4d7b490ac7fbb0fd2d2 (patch)
tree515b2b2e017329cbcada60e898fb5795fbceb5cd /src/core/vector3.rs
parenta43ab40a75e9d4c6ee3fbdd583bc93574db19124 (diff)
Abstracted lambertian into material
Diffstat (limited to 'src/core/vector3.rs')
-rw-r--r--src/core/vector3.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/vector3.rs b/src/core/vector3.rs
index ef067aa..ff5a678 100644
--- a/src/core/vector3.rs
+++ b/src/core/vector3.rs
@@ -1,7 +1,7 @@
//! Implements 3d vectors
//!
//! Also add more 3d math things needed for shading and 3d calculations.
-use crate::{Float, Number};
+use crate::{Float, Number, NEAR_ZERO};
use std::ops::{Mul, Sub, Add, DivAssign, Neg};
use std::fmt;
@@ -149,4 +149,13 @@ impl Vector3f {
)
}
+
+ /// Check if vector is close to [0, 0, 0]
+ ///
+ /// This is based on the NEAR_ZERO constant
+ pub fn near_zero(&self) -> bool {
+ (self.x.abs() < NEAR_ZERO) &&
+ (self.y.abs() < NEAR_ZERO) &&
+ (self.z.abs() < NEAR_ZERO)
+ }
}