From 8c78e3512a332eb16d4cd50679df3278282b7a3f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Aug 2024 21:53:41 +0200 Subject: [PATCH] Compute "identical max" based on tolerance --- crates/fj-core/src/validation/config.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/validation/config.rs b/crates/fj-core/src/validation/config.rs index a0e17372d..a28cadf1e 100644 --- a/crates/fj-core/src/validation/config.rs +++ b/crates/fj-core/src/validation/config.rs @@ -44,10 +44,9 @@ impl ValidationConfig { pub fn from_tolerance(tolerance: impl Into) -> Self { let tolerance = tolerance.into(); - // This value was chosen pretty arbitrarily. Seems small enough to catch - // errors. If it turns out it's too small (because it produces false - // positives due to floating-point accuracy issues), we can adjust it. - let identical_max_distance = Scalar::from_f64(5e-14); + // This value can't be smaller than the tolerance. If it is, we'll get + // validation errors everywhere, just from numerical noise. + let identical_max_distance = tolerance.inner() * 10.; // This value can't be smaller than `identical_max_distance`. Otherwise // we can have distinct points that satisfy this constraint, but must be