mirror of
https://github.com/30hours/3lips.git
synced 2024-11-08 12:25:42 +00:00
Remove numpy from geometry
This commit is contained in:
parent
8d40699da9
commit
6d9027f1be
1 changed files with 13 additions and 14 deletions
|
@ -4,7 +4,6 @@
|
|||
"""
|
||||
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
class Geometry:
|
||||
|
||||
|
@ -48,25 +47,25 @@ class Geometry:
|
|||
e = 8.1819190842622e-2
|
||||
|
||||
# Calculations:
|
||||
b = np.sqrt(a**2 * (1 - e**2))
|
||||
ep = np.sqrt((a**2 - b**2) / b**2)
|
||||
p = np.sqrt(x**2 + y**2)
|
||||
th = np.arctan2(a * z, b * p)
|
||||
lon = np.arctan2(y, x)
|
||||
lat = np.arctan2((z + ep**2 * b * np.sin(th)**3), (p - e**2 * a * np.cos(th)**3))
|
||||
N = a / np.sqrt(1 - e**2 * np.sin(lat)**2)
|
||||
alt = p / np.cos(lat) - N
|
||||
b = math.sqrt(a**2 * (1 - e**2))
|
||||
ep = math.sqrt((a**2 - b**2) / b**2)
|
||||
p = math.sqrt(x**2 + y**2)
|
||||
th = math.atan2(a * z, b * p)
|
||||
lon = math.atan2(y, x)
|
||||
lat = math.atan2((z + ep**2 * b * math.sin(th)**3), (p - e**2 * a * math.cos(th)**3))
|
||||
N = a / math.sqrt(1 - e**2 * math.sin(lat)**2)
|
||||
alt = p / math.cos(lat) - N
|
||||
|
||||
# Return lon in range [0, 2*pi)
|
||||
lon = np.mod(lon, 2 * np.pi)
|
||||
lon = lon % (2 * math.pi)
|
||||
|
||||
# Correct for numerical instability in altitude near exact poles:
|
||||
# (after this correction, error is about 2 millimeters, which is about
|
||||
# the same as the numerical precision of the overall function)
|
||||
k = np.logical_and(np.abs(x) < 1e-10, np.abs(y) < 1e-10)
|
||||
alt = np.where(k, np.abs(z) - b, alt)
|
||||
k = abs(x) < 1e-10 and abs(y) < 1e-10
|
||||
alt = abs(z) - b if k else alt
|
||||
|
||||
lat = np.degrees(lat)
|
||||
lon = np.degrees(lon)
|
||||
lat = math.degrees(lat)
|
||||
lon = math.degrees(lon)
|
||||
|
||||
return lat, lon, alt
|
Loading…
Reference in a new issue