Skip to content

fix: handle zenith/nadir azimuth in ecef2geodetic_los#1131

Merged
olemke merged 3 commits into
atmtools:mainfrom
olemke:improve-zenith-aa-handling
Jun 12, 2026
Merged

fix: handle zenith/nadir azimuth in ecef2geodetic_los#1131
olemke merged 3 commits into
atmtools:mainfrom
olemke:improve-zenith-aa-handling

Conversation

@olemke

@olemke olemke commented Jun 3, 2026

Copy link
Copy Markdown
Member

The ecef2geodetic_los function previously relied on enu2los for azimuth, which becomes geometrically undefined at zenith and nadir. This PR detects those cases and returns azimuth 0.0 by convention, while restoring the pole/ENU-based fallback for other viewing geometries.
A small refactor swaps the manual Euclidean norm in ecef_distance for std::hypot.
A new interactive matplotlib test exercises the full LOS round-trip against a Python port of the legacy iterative solver.

Changes

  • src/core/geodesy/geodetic.cpp: In ecef2geodetic_los, detect zenith/nadir viewing geometries and return azimuth 0.0; otherwise preserve the existing pole-aware and ENU-based azimuth fallbacks. Switch ecef_distance to std::hypot.
  • src/core/tests/geodetic_interactive.py: Interactive matplotlib tool that round-trips geodetic LOS through geodetic_los2ecef and both the production and a Python port of the retired iterative ecef2geodetic_los, plotting azimuth, zenith, altitude, latitude, and longitude with their differences over a full azimuth sweep driven by sliders.

olemke added 3 commits June 3, 2026 09:39
The azimuth at zenith and nadir is geometrically undefined, so set
it to 0.0 by convention. The pole case (latitude > POLELATZZZ) and
the default ENU-based azimuth are handled in the calling function
ecef2geodetic_los rather than inside enu2los, because:

  * enu2los is a pure ENU -> LOS conversion that has no notion of
    position, latitude, or the original ECEF components. The pole
    fallback needs decef, and the zenith/nadir check is a
    caller-specific convention, not a property of the ENU direction
    itself.
  * Keeping enu2los free of geographic context preserves it as a
    reusable utility (e.g. the los2enu / enu2los pair in this file
    is symmetric, and los2enu carries no special handling either).
Adds a matplotlib slider-driven script that round-trips a geodetic
position and LOS direction through geodetic_los2ecef and back, comparing
the production ecef2geodetic_los against a Python re-implementation of
the legacy iterative path used in test_geodetic_aa.cpp.
@olemke olemke force-pushed the improve-zenith-aa-handling branch from edc2c8d to 77be881 Compare June 3, 2026 13:16
@olemke olemke merged commit 4cf96c5 into atmtools:main Jun 12, 2026
9 checks passed
@olemke olemke deleted the improve-zenith-aa-handling branch June 12, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant