Add GeographicLib v2.4 parity for trig accuracy, Hypot3, and Jacobi amplitude#2
Add GeographicLib v2.4 parity for trig accuracy, Hypot3, and Jacobi amplitude#2
Conversation
Agent-Logs-Url: https://github.com/habizdev/GeographicLib.NET/sessions/c8e70dc3-399a-43d9-9694-d0cb700f65bb Co-authored-by: AgileJoshua <564800+AgileJoshua@users.noreply.github.com>
Agent-Logs-Url: https://github.com/habizdev/GeographicLib.NET/sessions/c8e70dc3-399a-43d9-9694-d0cb700f65bb Co-authored-by: AgileJoshua <564800+AgileJoshua@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the C# GeographicLib port to align with upstream GeographicLib v2.4 math surface and exact-angle degree-based trig behavior.
Changes:
- Added
MathEx.Hypot3andEllipticFunction.Am(Jacobi amplitude) APIs. - Updated degree-based trig entry points (
Sind,Cosd,SinCosd,SinCosde) to return upstream v2.4 exact reduced-angle results for special angles. - Added/updated regression tests and README changelog entry reflecting the v2.4 parity work.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds a 2.4.0 (unreleased) changelog entry describing new APIs and trig behavior fix. |
| GeographicLib/MathEx.cs | Introduces Hypot3 and centralized special-angle handling for degree trig functions. |
| GeographicLib/EllipticFunction.cs | Exposes new public Am overloads forwarding to the private implementation. |
| GeographicLib/EllipticFunction.Priv.cs | Implements Jacobi amplitude Am and Am(..., out sn, out cn, out dn). |
| GeographicLibTests/MathExTests.cs | Adds exact-angle trig assertions and Hypot3 tests. |
| GeographicLibTests/EllipticFunctionTests.cs | Adds tests for Am special cases and consistency with Sncndn / inverse F. |
| GeographicLibTests/RhumbSolveTests.cs | Updates a near-pole golden value impacted by the trig changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!(c[l] > tol * a[l])) | ||
| break; | ||
| } | ||
|
|
There was a problem hiding this comment.
In Am, the AGM loop can exit because l reaches num_ (when GEOGRAPHICLIB_PANIC is false and the convergence test never triggers). In that case l == num_ and the subsequent a[l]/c[l] indexing will throw IndexOutOfRangeException. Please clamp l to num_ - 1 (or decrement when the loop ends via the iteration limit), or allocate a/c with length num_ + 1 to make the indexing safe on non-convergence paths.
| if (l >= num_) | |
| l = num_ - 1; |
This updates the C# port to cover the user-visible GeographicLib v2.4 library delta from the upstream C++ release. The parity work focuses on the new math APIs and the exact-angle trigonometric behavior changes introduced in v2.4.
v2.4 math parity
MathEx.Hypot3(double x, double y, double z).EllipticFunction.Am(double x)andEllipticFunction.Am(double x, out double sn, out double cn, out double dn).Exact-angle trig behavior
MathEx.Sind,MathEx.Cosd,MathEx.SinCosd, andMathEx.SinCosdeto return the upstream v2.4 exact reduced-angle values for multiples of 30°, 45°, and 60°.Regression coverage
Sind/Cosd/SinCosd/SinCosderesults,Hypot3,EllipticFunction.Amspecial cases and consistency withSncndn/ inverseF.Version documentation
2.4.0changelog entry inREADME.mdsummarizing the parity additions.Example of the new v2.4 surface:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
geographiclib.sourceforge.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either: