Repository navigation
Spherical precision fixes - #143
Merged
pomadchin merged 4 commits intoNov 14, 2026
Merged
Conversation
pomadchin
commented
Nov 14, 2026
Comment on lines
+53
to
+62
| double sinc = Math.sin(c); | ||
| double sinphi = Math.sin(lpphi); | ||
| double cosphi = Math.cos(lpphi); | ||
| // sin(d) from hypot() and d from atan2() keep the relative accuracy near the | ||
| // origin, where acos() of a value close to 1 did not (as in PROJ) | ||
| double sind = Math.hypot(cosphi * sinc, sinphi); | ||
| // d / sin(d), with limit 1 at the origin | ||
| double a = sind == 0. ? 1. : Math.atan2(sind, cosphi * Math.cos(c)) / sind; | ||
| out.x = 2. * cosphi * sinc * a; | ||
| out.y = sinphi * a; |
Member
Author
There was a problem hiding this comment.
pomadchin
commented
Nov 14, 2026
Comment on lines
+105
to
+119
| // c is the angular distance to (phi, lam). As in PROJ, sin(c) from hypot() and | ||
| // c from atan2() keep the forward accurate near the centre, unlike acos(cos(c)); | ||
| // only points within TOL of cos(c) = -1 (the antipode) are rejected | ||
| double s0 = mode == EQUATOR ? 0. : sinphi0, c0 = mode == EQUATOR ? 1. : cosphi0; | ||
| double sinlam = Math.sin(lam); | ||
| double cosphiCoslam = cosphi * coslam; | ||
| double cosc = s0 * sinphi + c0 * cosphiCoslam; | ||
| double t = c0 * sinphi - s0 * cosphiCoslam; | ||
| double sinc = Math.hypot(cosphi * sinlam, t); | ||
| if (cosc < TOL - 1.) | ||
| throw new ProjectionException(); | ||
| // c / sin(c), with limit 1 at the centre | ||
| double k = sinc == 0. ? 1. : Math.atan2(sinc, cosc) / sinc; | ||
| xy.x = k * cosphi * sinlam; | ||
| xy.y = k * t; |
Member
Author
There was a problem hiding this comment.
pomadchin
force-pushed
the
spherical-precision-proj-master
branch
from
November 14, 2026 14:33
2d54bb8 to
e4a4e27
Compare
pomadchin
force-pushed
the
spherical-precision-proj-master
branch
from
November 14, 2026 14:35
e4a4e27 to
2939cbc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports some of the bug fixes from #140