aboutsummaryrefslogtreecommitdiff
path: root/src/core/vector3.rs
diff options
context:
space:
mode:
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)
+ }
}