summaryrefslogtreecommitdiff
path: root/src/geom/length.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/geom/length.rs')
-rw-r--r--src/geom/length.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/geom/length.rs b/src/geom/length.rs
index ecfe5616..951cef4f 100644
--- a/src/geom/length.rs
+++ b/src/geom/length.rs
@@ -108,6 +108,11 @@ impl Length {
self.raw + 1e-6 >= other.raw
}
+ /// Compares two lengths for whether they are approximately equal.
+ pub fn approx_eq(self, other: Self) -> bool {
+ self == other || (self - other).to_raw().abs() < 1e-6
+ }
+
/// Whether the length is zero.
pub fn is_zero(self) -> bool {
self.raw == 0.0