From 34dfee032d9054f0dd0264dd3954c850b3f38fdb Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 1 Oct 2026 01:22:43 +0300 Subject: [PATCH] refactor(snap): keep the ellipse-arc parameter test private and plain Only snap.rs uses it; the full-turn checks collapse into one. Co-Authored-By: Claude Opus 5.5 --- src/snap.rs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/snap.rs b/src/snap.rs index a581f861c..68b94be50 100644 --- a/src/snap.rs +++ b/src/snap.rs @@ -3290,25 +3290,18 @@ fn arc_tangent_points( .collect() } -pub fn is_ellipse_param_on_arc(t: f64, start_param: f64, end_param: f64) -> bool { - let raw_sweep = end_param - start_param; - if (raw_sweep.abs() - std::f64::consts::TAU).abs() < 1e-9 - || raw_sweep.abs() >= std::f64::consts::TAU - 1e-9 - || raw_sweep.abs() < 1e-9 - { +/// Whether ellipse parameter `t` lies on the arc running counter-clockwise +/// from `start_param` to `end_param`. A zero or full-turn span is the whole +/// ellipse. +fn is_ellipse_param_on_arc(t: f64, start_param: f64, end_param: f64) -> bool { + use std::f64::consts::TAU; + let span = end_param - start_param; + if span.abs() < 1e-9 || span.abs() >= TAU - 1e-9 { return true; } - let sweep = raw_sweep.rem_euclid(std::f64::consts::TAU); - let sweep = if sweep.abs() <= 1e-9 && raw_sweep.abs() > 1e-5 { - std::f64::consts::TAU - } else { - sweep - }; - if sweep >= std::f64::consts::TAU - 1e-9 { - return true; - } - let d_t = (t - start_param).rem_euclid(std::f64::consts::TAU); - d_t <= sweep + 1e-6 || d_t >= std::f64::consts::TAU - 1e-6 + let sweep = span.rem_euclid(TAU); + let along = (t - start_param).rem_euclid(TAU); + along <= sweep + 1e-6 || along >= TAU - 1e-6 } fn planar_ellipse_tangent_points(