From ffe2b67f5962a1bdafbdaa9862d7623c16558cfd Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 12 Nov 2026 23:06:42 +0100 Subject: core: consolidate the three ad-hoc azimuth wraps into wrap_angle ProjArgs::from_params now normalizes the mountain azimuth centrally, so the two remaining hand-rolled wraps are redundant: * get_coordinates dropped its single-step +/-2pi normalization (a leftover of the C++ original that could not even handle azimuths more than one full turn off); from_params covers it strictly more generally. * is_visible's abs-mod-fold became one wrap_angle call. The explicit is_finite guard stays (wrap_angle's NaN would silently pass the >= view_angle test when max_view_angle is 0). No behavior change: 35 core + 13 golden tests, including the Finding 1 regression test and all north/wide-panorama tests, pass unmodified. --- crates/gipfel-core/src/panorama.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/gipfel-core/src/panorama.rs') diff --git a/crates/gipfel-core/src/panorama.rs b/crates/gipfel-core/src/panorama.rs index b8ce342..4289b6b 100644 --- a/crates/gipfel-core/src/panorama.rs +++ b/crates/gipfel-core/src/panorama.rs @@ -409,15 +409,12 @@ impl Panorama { if !alph.is_finite() || !self.parms.a_center.is_finite() { return false; } - // Wrap into [0, 2pi) before the fold: a_center may lie outside - // [-pi, pi] (user enters "400 deg", or a fit leaves it unnormalized). - // Without this, |alph - a_center| > 2pi turned the single fold below - // into a NEGATIVE distance, which passed every comparison and made + // Shortest arc to the view center. wrap_angle also covers azimuths + // far outside [-pi, pi] (user enters "400 deg", a fit leaves it + // unnormalized); the old single fold turned |alph - a_center| > 2pi + // into a NEGATIVE distance that passed every comparison and made // hills behind the camera visible (GipfelFind.lean Finding 1). - let mut center_dist = (alph - self.parms.a_center).abs() % (2.0 * PI); - if center_dist > PI { - center_dist = 2.0 * PI - center_dist; - } + let center_dist = crate::projection::wrap_angle(alph - self.parms.a_center).abs(); if center_dist >= self.proj.get_view_angle() { return false; } -- cgit v1.2.3