Skip to content

library: UTM, MGRS, magnetic field, GPS time and celestial navigation - #1875

Open
Wiljea wants to merge 7 commits into
c3d:devfrom
Wiljea:navigation-functions
Open

Wiljea wants to merge 7 commits into
c3d:devfrom
Wiljea:navigation-functions

Conversation

@Wiljea

@Wiljea Wiljea commented Nov 5, 2026

Copy link
Copy Markdown

This completes the navigation part of my Aeronautics plan. It is based on #1874, which moves the existing Navigation and Aeronautics functions to subdirectories; please merge #1874 first. Its help examples also need #1868 and #1872: without them, two examples of MGRS→LL and Formula can fail depending on memory layout.

Function Library

Navigation/Geodesy, thirteen functions, in library/Navigation:

Function Purpose Checked against
LL→UTM, UTM→LL UTM coordinates, Krüger series (Karney 2011), zones of Norway and Svalbard GeographicLib GeoConvert, to the millimetre; Snyder (1987)
LL→MGRS, MGRS→LL military grid references, NGA.SIG.0012 GeoConvert; 200 000 random round trips
WMM magnetic declination, inclination and intensities, WMM2025 (public domain) the twelve NOAA test values
TrackLen length of a track or route, by Vincenty GeographicLib
PolyArea area of a polygon, sphere of the same area GeographicLib: about 0.002% for a province, documented
LLH→ENU, ENU→LLH local East, North, Up frame computed reference
UTC→GPS, GPS→UTC GPS week and time of week, from 2017 on computed reference
LL→DMS, LL→DDM position as text —

Celestial Navigation, a new section, six functions in library/Celestial: AriesGHA, SunGP, SightRed, Sextant, MeridLat and LOPFix. They are checked against the Celestial Navigation Data service of the US Naval Observatory and against Bowditch, §403. The Sun is within about 0.2′ of the USNO on the dates tried; its formula is stated to about 1′. The Moon, the planets and a star catalogue are not included.

Equation Library

A new section Celestial Navigation: Sight Reduction, Altitude Corrections, Meridian Altitude and Amplitude, with 23 variables and three help figures.

On a DM32

All the functions were tried on a DM32 with a test build. WMM takes 920 ms. Dates are passed as decimals in UTC→GPS, GPS→UTC, AriesGHA and SunGP, because a DM32 rejects integer dates (#1873).

Tests

Full test suite on this branch, with #1868 and #1872 applied: DB48x and DB50x, no failure.

Author & design: Jean Wilson
🤖 Generated with Claude Code

Wiljea and others added 7 commits November 5, 2026 10:30
Nineteen functions of the Navigation and Aeronautics sections were in the
root of the library. Move them to library/Navigation and library/Aeronautics,
as Astronomy or Chemistry do. The LIB menu does not change, since it is
defined by config/library.csv. PeriSel stays in the root, since
doc/config/library.md uses its path as an example.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LL→UTM and UTM→LL use the Krüger series in the form of Karney (2011), to
order 4, with the zone exceptions of Norway and Svalbard. LL→MGRS and
MGRS→LL use the AA lettering of NGA.SIG.0012. Results agree to the
millimetre with GeographicLib's GeoConvert on four test points.

The files go in library/Navigation, like the functions moved there by
the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WMM gives the magnetic declination, the inclination, and the horizontal and
total intensities at a point and date, from the coefficients of WMM2025 by
NOAA and the British Geological Survey, which are in the public domain.

Checked against the test values of NOAA: the reference computation matches
all twelve, and the calculator matches it on the six that were tried.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TrackLen sums geodesic distances along a track or a route. PolyArea gives the
area of a polygon from the spherical excess on the sphere of the same area,
which differs from GeographicLib by about 0.002% for a province, and is
documented. LLH→ENU and ENU→LLH work in a local East, North, Up frame. UTC→GPS
and GPS→UTC convert to and from GPS week and time of week, from 2017 on, with an
offset of 18 s. LL→DMS and LL→DDM format a position as text.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Function Library gains AriesGHA, SunGP, SightRed, Sextant, MeridLat and
LOPFix. The Equation Library gains Sight Reduction, Altitude Corrections,
Meridian Altitude and Amplitude, with three figures in the help.

Checked against the Celestial Navigation Data service of the US Naval
Observatory, and against Bowditch, section 403. The Sun is within about 0.2'
of the USNO on the three dates tried; its formula is stated to about 1'. The
Moon, the planets and a star catalogue are not included.

Also remove command names in backticks from the help of WMM, UTC→GPS and
GPS→UTC, since such a link takes the Enter key from the examples.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a DM32, DDays, JDN and Date+ reject every integer date with "Invalid date",
while the same date written as a decimal works (c3d#1873). These four functions
now convert their date with →Num and write their epochs as decimals, so that
they work on the calculator until that is fixed. Results are unchanged.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a DM32, a date unit whose value is an integer is displayed as "Invalid
date", even the result of Date (c3d#1873), while the same date as a decimal is
displayed correctly. GPS→UTC now converts the date it computes to a decimal.
The value and its display on the simulator are unchanged.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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