Expanded the fix for issue #347.

I tried more distant objects like Jupiter ... Neptune.
This revealed that at increasing distances, the convergence
threshold in inverse_terra needed to increased also.
So now I use 1 AU as a baseline, and scale up linearly
for more distant objects.
This commit is contained in:
Don Cross
2024-05-27 17:07:30 -04:00
parent 0309762a64
commit 7c475fcada
21 changed files with 140 additions and 93 deletions

View File

@@ -1435,6 +1435,7 @@ def _inverse_terra(ovec: List[float], st: float) -> Observer:
# Start with initial latitude estimate, based on a spherical Earth.
lat = math.atan2(z, p)
count = 0
distanceAu = max(1.0, math.hypot(ovec[0], ovec[1], ovec[2]))
while True:
count += 1
if count > 10:
@@ -1449,7 +1450,7 @@ def _inverse_terra(ovec: List[float], st: float) -> Observer:
radicand = cos2 + _EARTH_FLATTENING_SQUARED*sin2
denom = math.sqrt(radicand)
W = (factor*sin*cos)/denom - z*cos + p*sin
if abs(W) < 2.0e-8:
if abs(W) < distanceAu * 2.0e-8:
# The error is now negligible
break
# Error is still too large. Find the next estimate.