This commit is contained in:
2026-02-10 21:10:11 +01:00
parent db05f7b6db
commit 1fbfb555a4
9 changed files with 158 additions and 114 deletions

View File

@@ -6,6 +6,7 @@ import matplotlib.pyplot as plt
from typing import Tuple
from numpy.typing import NDArray
import math
from utils_angle import wrap_mpi_pi, wrap_0_2pi, wrap_mhalfpi_halfpi
class EllipsoidBiaxial:
@@ -218,8 +219,11 @@ class EllipsoidTriaxial:
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 - (
self.ax ** 2 + self.ay ** 2) * z ** 2)
if c1 ** 2 - 4 * c0 < 0:
if c1 ** 2 - 4 * c0 < -1e-9:
t2 = np.nan
raise Exception("t1, t2: Negativer Wurzelterm")
elif c1 ** 2 - 4 * c0 < 0:
t2 = 0
else:
t2 = (-c1 + sqrt(c1 ** 2 - 4 * c0)) / 2
if t2 == 0:
@@ -284,6 +288,11 @@ class EllipsoidTriaxial:
beta, lamb = np.broadcast_arrays(beta, lamb)
beta = np.where(
np.isclose(np.abs(beta), np.pi / 2, atol=1e-15),
beta * 8999999999999999 / 9000000000000000,
beta
)
B = self.Ex ** 2 * cos(beta) ** 2 + self.Ee ** 2 * sin(beta) ** 2
L = self.Ex ** 2 - self.Ee ** 2 * cos(lamb) ** 2
@@ -419,7 +428,7 @@ class EllipsoidTriaxial:
if delta_r > 1e-6:
raise Exception("Umrechnung cart2ell: Punktdifferenz")
return beta, lamb
return wrap_mhalfpi_halfpi(beta), wrap_mpi_pi(lamb)
except Exception as e:
# Wenn die Berechnung fehlschlägt auf Grund von sehr kleinem y, solange anpassen, bis Umrechnung ohne Fehler
@@ -605,8 +614,8 @@ class EllipsoidTriaxial:
if abs(zG) < eps:
phi = 0
return phi, lamb, h
wrap_mhalfpi_halfpi(phi), wrap_mpi_pi(lamb)
return wrap_mhalfpi_halfpi(phi), wrap_mpi_pi(lamb), h
def para2cart(self, u: float | NDArray, v: float | NDArray) -> NDArray:
"""
@@ -643,8 +652,8 @@ class EllipsoidTriaxial:
v = 2 * arctan2(v_check1, v_check2 + v_factor)
else:
v = pi/2 - 2 * arctan2(v_check2, v_check1 + v_factor)
return u, v
wrap_mhalfpi_halfpi(u), wrap_mpi_pi(v)
return wrap_mhalfpi_halfpi(u), wrap_mpi_pi(v)
def ell2para(self, beta: float, lamb: float) -> Tuple[float, float]:
"""
@@ -749,63 +758,71 @@ class EllipsoidTriaxial:
if __name__ == "__main__":
ell = EllipsoidTriaxial.init_name("BursaSima1980")
diff_list = []
diffs_para = []
diffs_ell = []
diffs_geod = []
points = []
for v_deg in range(-180, 181, 5):
for u_deg in range(-90, 91, 5):
v = wu.deg2rad(v_deg)
u = wu.deg2rad(u_deg)
point = ell.para2cart(u, v)
points.append(point)
ell = EllipsoidTriaxial.init_name("KarneyTest2024")
# cart = ell.ell2cart(np.pi/2, 0)
# print(cart)
# cart = ell.ell2cart(np.pi/2*8999999999999999/9000000000000000, 0)
# print(cart)
elli = ell.cart2ell([0, 0.0, 1/np.sqrt(2)])
print(elli)
elli = ell.cart2ell(point)
cart_elli = ell.ell2cart(elli[0], elli[1])
diff_ell = np.linalg.norm(point - cart_elli, axis=-1)
para = ell.cart2para(point)
cart_para = ell.para2cart(para[0], para[1])
diff_para = np.linalg.norm(point - cart_para, axis=-1)
geod = ell.cart2geod(point, "ligas3")
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])
diffs_ell.append([diff_ell])
diffs_para.append([diff_para])
diffs_geod.append([diff_geod3])
diff_list = np.array(diff_list)
diffs_ell = np.array(diffs_ell)
diffs_para = np.array(diffs_para)
diffs_geod = np.array(diffs_geod)
pass
points = np.array(points)
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
sc = ax.scatter(
points[:, 0],
points[:, 1],
points[:, 2],
c=diffs_ell, # Farbcode = diff
cmap='viridis', # Colormap
s=10 + 20 * diffs_ell, # optional: Größe abhängig vom diff
alpha=0.8
)
# Farbskala
cbar = plt.colorbar(sc)
cbar.set_label("diff")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
plt.show()
# ell = EllipsoidTriaxial.init_name("BursaSima1980")
# diff_list = []
# diffs_para = []
# diffs_ell = []
# diffs_geod = []
# points = []
# for v_deg in range(-180, 181, 5):
# for u_deg in range(-90, 91, 5):
# v = wu.deg2rad(v_deg)
# u = wu.deg2rad(u_deg)
# point = ell.para2cart(u, v)
# points.append(point)
#
# elli = ell.cart2ell(point)
# cart_elli = ell.ell2cart(elli[0], elli[1])
# diff_ell = np.linalg.norm(point - cart_elli, axis=-1)
#
# para = ell.cart2para(point)
# cart_para = ell.para2cart(para[0], para[1])
# diff_para = np.linalg.norm(point - cart_para, axis=-1)
#
# geod = ell.cart2geod(point, "ligas3")
# 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])
# diffs_ell.append([diff_ell])
# diffs_para.append([diff_para])
# diffs_geod.append([diff_geod3])
#
# diff_list = np.array(diff_list)
# diffs_ell = np.array(diffs_ell)
# diffs_para = np.array(diffs_para)
# diffs_geod = np.array(diffs_geod)
#
# pass
#
# points = np.array(points)
# fig = plt.figure()
# ax = fig.add_subplot(projection='3d')
#
# sc = ax.scatter(
# points[:, 0],
# points[:, 1],
# points[:, 2],
# c=diffs_ell, # Farbcode = diff
# cmap='viridis', # Colormap
# s=10 + 20 * diffs_ell, # optional: Größe abhängig vom diff
# alpha=0.8
# )
#
# # Farbskala
# cbar = plt.colorbar(sc)
# cbar.set_label("diff")
#
# ax.set_xlabel("X")
# ax.set_ylabel("Y")
# ax.set_zlabel("Z")
#
# plt.show()