Näherungslösung GHA 2
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import numpy as np
|
||||
from numpy import sin, cos, arctan, arctan2, sqrt, pi, arccos
|
||||
import winkelumrechnungen as wu
|
||||
import ausgaben as aus
|
||||
import jacobian_Ligas
|
||||
import matplotlib.pyplot as plt
|
||||
from typing import Tuple
|
||||
from numpy.typing import NDArray
|
||||
|
||||
|
||||
class EllipsoidBiaxial:
|
||||
@@ -162,18 +163,40 @@ class EllipsoidTriaxial:
|
||||
b = 1 / sqrt(2)
|
||||
return cls(ax, ay, b)
|
||||
|
||||
def func_H(self, x: float, y: float, z: float):
|
||||
def func_H(self, point: NDArray) -> float:
|
||||
"""
|
||||
Berechnung H
|
||||
Panou, Korakitis 2019 [43]
|
||||
:param point: Punkt
|
||||
:return: H
|
||||
"""
|
||||
x, y, z = point
|
||||
return x ** 2 + y ** 2 / (1 - self.ee ** 2) ** 2 + z ** 2 / (1 - self.ex ** 2) ** 2
|
||||
|
||||
def func_n(self, x: float, y: float, z: float, H: float = None):
|
||||
def func_n(self, point: NDArray, H: float = None) -> NDArray:
|
||||
"""
|
||||
Berechnung normalen Vektor
|
||||
Panou, Korakitis 2019 [9-12]
|
||||
:param point: Punkt
|
||||
:param H:
|
||||
:return:
|
||||
"""
|
||||
if H is None:
|
||||
H = self.func_H(x, y, z)
|
||||
H = self.func_H(point)
|
||||
sqrtH = sqrt(H)
|
||||
x, y, z = point
|
||||
return np.array([x / sqrtH,
|
||||
y / ((1 - self.ee ** 2) * sqrtH),
|
||||
z / ((1 - self.ex ** 2) * sqrtH)])
|
||||
|
||||
def func_t12(self, x, y, z):
|
||||
def func_t12(self, point: NDArray) -> Tuple[float, float]:
|
||||
"""
|
||||
Berechnung Wurzeln
|
||||
Panou, Korakitis 2019 [9-12]
|
||||
:param point: Punkt
|
||||
:return: Wurzeln t1, t2
|
||||
"""
|
||||
x, y, z = point
|
||||
c1 = x ** 2 + y ** 2 + z ** 2 - (self.ax ** 2 + self.ay ** 2 + self.b ** 2)
|
||||
c0 = (self.ax ** 2 * self.ay ** 2 + self.ax ** 2 * self.b ** 2 + self.ay ** 2 * self.b ** 2 -
|
||||
(self.ay ** 2 + self.b ** 2) * x ** 2 - (self.ax ** 2 + self.b ** 2) * y ** 2 - (
|
||||
@@ -184,7 +207,7 @@ class EllipsoidTriaxial:
|
||||
t1 = c0 / t2
|
||||
return t1, t2
|
||||
|
||||
def ellu2cart(self, beta: float, lamb: float, u: float) -> np.ndarray:
|
||||
def ellu2cart(self, beta: float, lamb: float, u: float) -> NDArray:
|
||||
"""
|
||||
Panou 2014 12ff.
|
||||
Elliptische Breite+Länge sind nicht gleich der geodätischen
|
||||
@@ -201,7 +224,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return np.array([x, y, z])
|
||||
|
||||
def cart2ellu(self, point: np.ndarray) -> tuple[float, float, float]:
|
||||
def cart2ellu(self, point: NDArray) -> Tuple[float, float, float]:
|
||||
"""
|
||||
Panou 2014 15ff.
|
||||
:param point: Punkt in kartesischen Koordinaten
|
||||
@@ -232,7 +255,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return beta, lamb, u
|
||||
|
||||
def ell2cart(self, beta: float | np.ndarray, lamb: float | np.ndarray) -> np.ndarray:
|
||||
def ell2cart(self, beta: float | NDArray, lamb: float | NDArray) -> NDArray:
|
||||
"""
|
||||
Panou, Korakitis 2019 2
|
||||
:param beta: elliptische Breite [rad]
|
||||
@@ -268,7 +291,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return xyz
|
||||
|
||||
def ell2cart_bektas(self, beta: float | np.ndarray, omega: float | np.ndarray):
|
||||
def ell2cart_bektas(self, beta: float | NDArray, omega: float | NDArray) -> NDArray:
|
||||
"""
|
||||
Bektas 2015
|
||||
:param beta:
|
||||
@@ -281,14 +304,13 @@ class EllipsoidTriaxial:
|
||||
|
||||
return np.array([x, y, z])
|
||||
|
||||
def ell2cart_karney(self, beta: float | np.ndarray, lamb: float | np.ndarray) -> np.ndarray:
|
||||
def ell2cart_karney(self, beta: float | NDArray, lamb: float | NDArray) -> NDArray:
|
||||
"""
|
||||
Karney 2025 Geographic Lib
|
||||
:param beta:
|
||||
:param lamb:
|
||||
:return:
|
||||
"""
|
||||
e = sqrt(self.ax**2 - self.b**2) / self.ay
|
||||
k = sqrt(self.ay**2 - self.b**2) / sqrt(self.ax**2 - self.b**2)
|
||||
k_ = sqrt(self.ax**2 - self.ay**2) / sqrt(self.ax**2 - self.b**2)
|
||||
X = self.ax * cos(lamb) * sqrt(k**2*cos(beta)**2+k_**2)
|
||||
@@ -296,11 +318,12 @@ class EllipsoidTriaxial:
|
||||
Z = self.b * sin(beta) * sqrt(k**2 + k_**2 * sin(lamb)**2)
|
||||
return np.array([X, Y, Z])
|
||||
|
||||
def cart2ell(self, point, eps=1e-12, maxI = 100) -> tuple[float, float]:
|
||||
def cart2ell(self, point: NDArray, eps: float = 1e-12, maxI: int = 100) -> Tuple[float, float]:
|
||||
"""
|
||||
Panou, Korakitis 2019 3f. (num)
|
||||
:param point:
|
||||
:param eps:
|
||||
:param maxI:
|
||||
:return:
|
||||
"""
|
||||
x, y, z = point
|
||||
@@ -323,10 +346,10 @@ class EllipsoidTriaxial:
|
||||
(self.b * self.Ee ** 2) / (2 * self.Ex) * sin(beta) * sin(2 * lamb) / sqrt(L)]])
|
||||
|
||||
N = J.T @ J
|
||||
det = N[0,0] * N[1,1] - N[0,1] * N[1,0]
|
||||
det = N[0, 0] * N[1, 1] - N[0, 1] * N[1, 0]
|
||||
if abs(det) < eps:
|
||||
det = eps
|
||||
N_inv = 1 / det * np.array([[N[1,1], -N[0,1]], [-N[1,0], N[0,0]]])
|
||||
N_inv = 1 / det * np.array([[N[1, 1], -N[0, 1]], [-N[1, 0], N[0, 0]]])
|
||||
delta_ell = N_inv @ J.T @ delta_l
|
||||
beta += delta_ell[0]
|
||||
lamb += delta_ell[1]
|
||||
@@ -344,7 +367,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return beta, lamb
|
||||
|
||||
def cart2ell_panou(self, point: np.ndarray) -> tuple[float, float]:
|
||||
def cart2ell_panou(self, point: NDArray) -> Tuple[float, float]:
|
||||
"""
|
||||
Panou, Korakitis 2019 2f. (analytisch -> Näherung)
|
||||
:param point: Punkt in kartesischen Koordinaten
|
||||
@@ -371,7 +394,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
# ---- Allgemeiner Fall -----
|
||||
|
||||
t1, t2 = self.func_t12(x, y, z)
|
||||
t1, t2 = self.func_t12(point)
|
||||
|
||||
num_beta = max(t1 - self.b ** 2, 0)
|
||||
den_beta = max(self.ay ** 2 - t1, 0)
|
||||
@@ -401,7 +424,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return beta, lamb
|
||||
|
||||
def cart2ell_bektas(self, point, eps=1e-12, maxI = 100) -> tuple[float, float]:
|
||||
def cart2ell_bektas(self, point: NDArray, eps: float = 1e-12, maxI: int = 100) -> Tuple[float, float]:
|
||||
"""
|
||||
Bektas 2015
|
||||
:param point:
|
||||
@@ -430,7 +453,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return phi, lamb
|
||||
|
||||
def geod2cart(self, phi: float | np.ndarray, lamb: float | np.ndarray, h: float) -> np.ndarray:
|
||||
def geod2cart(self, phi: float | NDArray, lamb: float | NDArray, h: float) -> NDArray:
|
||||
"""
|
||||
Ligas 2012, 250
|
||||
:param phi: geodätische Breite [rad]
|
||||
@@ -444,7 +467,7 @@ class EllipsoidTriaxial:
|
||||
zG = (v * (1-self.ex**2) + h) * sin(phi)
|
||||
return np.array([xG, yG, zG])
|
||||
|
||||
def cart2geod(self, point: np.ndarray, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> tuple[float, float, float]:
|
||||
def cart2geod(self, point: NDArray, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> Tuple[float, float, float]:
|
||||
"""
|
||||
Ligas 2012
|
||||
:param mode: ligas1, ligas2, oder ligas3
|
||||
@@ -513,7 +536,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
return phi, lamb, h
|
||||
|
||||
def para2cart(self, u: float | np.ndarray, v: float | np.ndarray) -> np.ndarray:
|
||||
def para2cart(self, u: float | NDArray, v: float | NDArray) -> NDArray:
|
||||
"""
|
||||
Panou, Korakitits 2020, 4
|
||||
:param u: Parameter u
|
||||
@@ -526,7 +549,7 @@ class EllipsoidTriaxial:
|
||||
z = np.broadcast_to(z, np.shape(x))
|
||||
return np.array([x, y, z])
|
||||
|
||||
def cart2para(self, point: np.ndarray) -> tuple[float, float]:
|
||||
def cart2para(self, point: NDArray) -> Tuple[float, float]:
|
||||
"""
|
||||
Panou, Korakitits 2020, 4
|
||||
:param point: Punkt in kartesischen Koordinaten
|
||||
@@ -551,31 +574,31 @@ class EllipsoidTriaxial:
|
||||
|
||||
return u, v
|
||||
|
||||
def ell2para(self, beta: float, lamb: float) -> tuple[float, float]:
|
||||
def ell2para(self, beta: float, lamb: float) -> Tuple[float, float]:
|
||||
cart = self.ell2cart(beta, lamb)
|
||||
return self.cart2para(cart)
|
||||
|
||||
def para2ell(self, u: float, v: float) -> tuple[float, float]:
|
||||
def para2ell(self, u: float, v: float) -> Tuple[float, float]:
|
||||
cart = self.para2cart(u, v)
|
||||
return self.cart2ell(cart)
|
||||
|
||||
def para2geod(self, u: float, v: float, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> tuple[float, float, float]:
|
||||
def para2geod(self, u: float, v: float, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> Tuple[float, float, float]:
|
||||
cart = self.para2cart(u, v)
|
||||
return self.cart2geod(cart, mode, maxIter, maxLoa)
|
||||
|
||||
def geod2para(self, phi: float, lamb: float, h: float) -> tuple[float, float]:
|
||||
def geod2para(self, phi: float, lamb: float, h: float) -> Tuple[float, float]:
|
||||
cart = self.geod2cart(phi, lamb, h)
|
||||
return self.cart2para(cart)
|
||||
|
||||
def ell2geod(self, beta: float, lamb: float, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> tuple[float, float, float]:
|
||||
def ell2geod(self, beta: float, lamb: float, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> Tuple[float, float, float]:
|
||||
cart = self.ell2cart(beta, lamb)
|
||||
return self.cart2geod(cart, mode, maxIter, maxLoa)
|
||||
|
||||
def geod2ell(self, phi: float, lamb: float, h: float) -> tuple[float, float]:
|
||||
def geod2ell(self, phi: float, lamb: float, h: float) -> Tuple[float, float]:
|
||||
cart = self.geod2cart(phi, lamb, h)
|
||||
return self.cart2ell(cart)
|
||||
|
||||
def point_on(self, point: np.ndarray) -> bool:
|
||||
def point_on(self, point: NDArray) -> bool:
|
||||
"""
|
||||
Test, ob ein Punkt auf dem Ellipsoid liegt.
|
||||
:param point: kartesische 3D-Koordinaten
|
||||
@@ -587,17 +610,17 @@ class EllipsoidTriaxial:
|
||||
else:
|
||||
return False
|
||||
|
||||
def cartonell(self, point: np.ndarray) -> tuple[np.ndarray, float, float, float]:
|
||||
def cartonell(self, point: NDArray) -> NDArray:
|
||||
"""
|
||||
Berechnung des Lotpunktes auf einem Ellipsoiden
|
||||
:param point: Punkt in kartesischen Koordinaten, der gelotet werden soll
|
||||
:return: Lotpunkt in kartesischen Koordinaten, geodätische Koordinaten des Punktes
|
||||
:return: Lotpunkt in kartesischen Koordinaten
|
||||
"""
|
||||
phi, lamb, h = self.cart2geod(point, "ligas3")
|
||||
x, y, z = self. geod2cart(phi, lamb, 0)
|
||||
return np.array([x, y, z]), phi, lamb, h
|
||||
p = self. geod2cart(phi, lamb, 0)
|
||||
return p
|
||||
|
||||
def cartellh(self, point: np.ndarray, h: float) -> np.ndarray:
|
||||
def cartellh(self, point: NDArray, h: float) -> NDArray:
|
||||
"""
|
||||
Punkt auf Ellipsoid hoch loten
|
||||
:param point: Punkt auf dem Ellipsoid
|
||||
@@ -635,7 +658,7 @@ if __name__ == "__main__":
|
||||
cart_geod = ell.geod2cart(geod[0], geod[1], geod[2])
|
||||
diff_geod3 = np.linalg.norm(point - cart_geod, axis=-1)
|
||||
|
||||
diff_list.append([v_deg, u_deg, diff_ell, diff_para, diff_geod3]) #
|
||||
diff_list.append([v_deg, u_deg, diff_ell, diff_para, diff_geod3])
|
||||
diffs_ell.append([diff_ell])
|
||||
diffs_para.append([diff_para])
|
||||
diffs_geod.append([diff_geod3])
|
||||
|
||||
Reference in New Issue
Block a user