diff options
| -rw-r--r-- | crates/gipfel-core/src/panorama.rs | 13 | ||||
| -rw-r--r-- | crates/gipfel-core/src/projection/mod.rs | 14 | ||||
| -rw-r--r-- | dist/gipfel/gipfel_bg.wasm | bin | 555746 -> 555907 bytes |
3 files changed, 8 insertions, 19 deletions
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; } diff --git a/crates/gipfel-core/src/projection/mod.rs b/crates/gipfel-core/src/projection/mod.rs index 360c377..d0221e8 100644 --- a/crates/gipfel-core/src/projection/mod.rs +++ b/crates/gipfel-core/src/projection/mod.rs @@ -172,18 +172,10 @@ pub trait Projection: Send + Sync { NAN } - /// Project azimuth/elevation to image coordinates (relative to image center), - /// normalizing azimuth around the view center like the C++ original. + /// Project azimuth/elevation to image coordinates (relative to image + /// center). Azimuth normalization around the view center happens once, + /// centrally, in [`ProjArgs::from_params`]. fn get_coordinates(&self, alph: f64, elev: f64, parms: &ViewParams) -> (f64, f64) { - let mut alph = alph; - let pi = crate::hill::PI; - - if alph - parms.a_center > pi { - alph -= 2.0 * pi; - } else if alph - parms.a_center < -pi { - alph += 2.0 * pi; - } - let args = ProjArgs::from_params(parms, alph, elev); (self.mac_x(args), self.mac_y(args)) } diff --git a/dist/gipfel/gipfel_bg.wasm b/dist/gipfel/gipfel_bg.wasm Binary files differindex 01bc96c..18ec619 100644 --- a/dist/gipfel/gipfel_bg.wasm +++ b/dist/gipfel/gipfel_bg.wasm |
