From 4139fbc3549cfdd7a677c63a7df4ec6449777149 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 14 Dec 2025 16:13:55 +0100 Subject: [PATCH] kleine Anpassungen --- GHA_triaxial/panou.py | 4 +-- dashborad.py => dashboard.py | 29 +++++++--------- ellipsoide.py | 65 +++++++++++++++++++++++++----------- show_constant_lines.py | 30 +++++++++++++++++ 4 files changed, 90 insertions(+), 38 deletions(-) rename dashborad.py => dashboard.py (95%) create mode 100644 show_constant_lines.py diff --git a/GHA_triaxial/panou.py b/GHA_triaxial/panou.py index cb0be11..9f7c6ca 100644 --- a/GHA_triaxial/panou.py +++ b/GHA_triaxial/panou.py @@ -13,7 +13,7 @@ import GHA_triaxial.numeric_examples_panou as nep def gha1_num_old(ell: ellipsoide.EllipsoidTriaxial, point, alpha0, s, num): - phi, lamb, h = ell.cart2geod("ligas3", point) + phi, lamb, h = ell.cart2geod(point, "ligas3") x, y, z = ell.geod2cart(phi, lamb, 0) p, q = ell.p_q(x, y, z) @@ -50,7 +50,7 @@ def buildODE(ell): return ODE def gha1_num(ell, point, alpha0, s, num): - phi, lam, _ = ell.cart2geod("ligas3", point) + phi, lam, _ = ell.cart2geod(point, "ligas3") x0, y0, z0 = ell.geod2cart(phi, lam, 0) p, q = ell.p_q(x0, y0, z0) diff --git a/dashborad.py b/dashboard.py similarity index 95% rename from dashborad.py rename to dashboard.py index cb72040..bea0934 100644 --- a/dashborad.py +++ b/dashboard.py @@ -20,9 +20,8 @@ def ellipsoid_figure(ax, ay, b, pts=None, lines=None, title="Dreiachsiges Ellips u = np.linspace(-np.pi/2, np.pi/2, 80) v = np.linspace(-np.pi, np.pi, 160) U, V = np.meshgrid(u, v) - X = ax * np.cos(U) * np.cos(V) - Y = ay * np.cos(U) * np.sin(V) - Z = b * np.sin(U) + ell = EllipsoidTriaxial(ax, ay, b) + X, Y, Z = ell.para2cart(U, V) fig = go.Figure() fig.add_trace(go.Surface( @@ -35,11 +34,9 @@ def ellipsoid_figure(ax, ay, b, pts=None, lines=None, title="Dreiachsiges Ellips meridians_deg = np.arange(0, 360, 15) lat_line = np.linspace(-np.pi/2, np.pi/2, 240) for lon_deg in meridians_deg: - lam = np.deg2rad(lon_deg) - phi = lat_line - xm = ax * np.cos(phi) * np.cos(lam) - ym = ay * np.cos(phi) * np.sin(lam) - zm = b * np.sin(phi) + um = np.deg2rad(lon_deg) + vm = lat_line + xm, ym, zm = ell.para2cart(um, vm) fig.add_trace(go.Scatter3d( x=xm, y=ym, z=zm, mode="lines", line=dict(width=1, color="black"), @@ -48,11 +45,9 @@ def ellipsoid_figure(ax, ay, b, pts=None, lines=None, title="Dreiachsiges Ellips parallels_deg = np.arange(-75, 90, 15) lon_line = np.linspace(0, 2*np.pi, 360) for lat_deg in parallels_deg: - phi = np.deg2rad(lat_deg) - lam = lon_line - xp = ax * np.cos(phi) * np.cos(lam) - yp = ay * np.cos(phi) * np.sin(lam) - zp = b * np.sin(phi) * np.ones_like(lam) + vp = np.deg2rad(lat_deg) + up = lon_line + xp, yp, zp = ell.para2cart(up, vp) fig.add_trace(go.Scatter3d( x=xp, y=yp, z=zp, mode="lines", line=dict(width=1, color="black"), @@ -70,14 +65,14 @@ def ellipsoid_figure(ax, ay, b, pts=None, lines=None, title="Dreiachsiges Ellips )) if lines: - for (p1, p2) in lines: + for (p1, p2, color) in lines: xline = [p1[0], p2[0]] yline = [p1[1], p2[1]] zline = [p1[2], p2[2]] fig.add_trace(go.Scatter3d( x=xline, y=yline, z=zline, mode="lines", - line=dict(width=4, color="red"), + line=dict(width=4, color=color), showlegend=False )) @@ -348,7 +343,7 @@ def calc_and_plot(n1, n2, fig = ellipsoid_figure( ell.ax, ell.ay, ell.b, pts=[("P1", p1, "black"), ("P2", p2, "red")], - lines=[(p1, p2)], + lines=[(p1, p2, "red")], title="Erste Hauptaufgabe - analystisch" ) @@ -371,7 +366,7 @@ def calc_and_plot(n1, n2, fig = ellipsoid_figure( ell.ax, ell.ay, ell.b, pts=[("P1", p1, "black"), ("P2", p2, "red")], - lines=[(p1, p2)], + lines=[(p1, p2, "red")], title=f"Zweite Hauptaufgabe - numerisch" ) out2 = f"a₁₂={np.rad2deg(alpha_1):.6f}°, a₂₁={np.rad2deg(alpha_2):.6f}°, s={s12:.4f} m" diff --git a/ellipsoide.py b/ellipsoide.py index 27e763c..8d6631c 100644 --- a/ellipsoide.py +++ b/ellipsoide.py @@ -151,10 +151,15 @@ class EllipsoidTriaxial: b = 6356078.96290 return cls(ax, ay, b) elif name == "Fiction": - ax = 5500000 - ay = 4500000 + ax = 6000000 + ay = 5000000 b = 4000000 return cls(ax, ay, b) + elif name == "KarneyTest2024": + ax = np.sqrt(2) + ay = 1 + b = 1 / np.sqrt(2) + return cls(ax, ay, b) def point_on(self, point: np.ndarray) -> bool: """ @@ -171,7 +176,7 @@ class EllipsoidTriaxial: def ellu2cart(self, beta: float, lamb: float, u: float) -> np.ndarray: """ Panou 2014 12ff. - Ellipsoidische Breite+Länge sind nicht gleich der geodätischen + Elliptische Breite+Länge sind nicht gleich der geodätischen Verhältnisse des Ellipsoids bekannt, Größe verändern bis Punkt erreicht, dann ist u die Größe entlang der z-Achse :param beta: ellipsoidische Breite [rad] @@ -200,8 +205,8 @@ class EllipsoidTriaxial: def ell2cart(self, beta: float, lamb: float) -> np.ndarray: """ Panou, Korakitis 2019 2 - :param beta: ellipsoidische Breite [rad] - :param lamb: ellipsoidische Länge [rad] + :param beta: elliptische Breite [rad] + :param lamb: elliptische Länge [rad] :return: Punkt in kartesischen Koordinaten """ if beta == -np.pi/2: @@ -228,7 +233,7 @@ class EllipsoidTriaxial: """ Panou 2014 15ff. :param point: Punkt in kartesischen Koordinaten - :return: ellipsoidische Breite, ellipsoidische Länge, Größe entlang der z-Achse + :return: elliptische Breite, elliptische Länge, Größe entlang der z-Achse """ x, y, z = point c2 = self.ax**2 + self.ay**2 + self.b**2 - x**2 - y**2 - z**2 @@ -259,7 +264,7 @@ class EllipsoidTriaxial: """ Panou, Korakitis 2019 2f. :param point: Punkt in kartesischen Koordinaten - :return: ellipsoidische Breite, ellipsoidische Länge + :return: elliptische Breite, elliptische Länge """ x, y, z = point @@ -316,7 +321,7 @@ class EllipsoidTriaxial: return beta, lamb - def cart2geod(self, mode: str, point: np.ndarray, maxIter: int = 30, maxLoa: float = 0.005) -> tuple[float, float, float]: + def cart2geod(self, point: np.ndarray, mode: str = "ligas3", maxIter: int = 30, maxLoa: float = 0.005) -> tuple[float, float, float]: """ Ligas 2012 :param mode: ligas1, ligas2, oder ligas3 @@ -405,7 +410,7 @@ class EllipsoidTriaxial: :param point: Punkt in kartesischen Koordinaten, der gelotet werden soll :return: Lotpunkt in kartesischen Koordinaten, geodätische Koordinaten des Punktes """ - phi, lamb, h = self.cart2geod("ligas3", point) + phi, lamb, h = self.cart2geod(point, "ligas3") x, y, z = self. geod2cart(phi, lamb, 0) return np.array([x, y, z]), phi, lamb, h @@ -416,7 +421,7 @@ class EllipsoidTriaxial: :param h: Höhe über dem Ellipsoid :return: hochgeloteter Punkt """ - phi, lamb, _ = self.cart2geod("ligas3", point) + phi, lamb, _ = self.cart2geod(point, "ligas3") pointH = self. geod2cart(phi, lamb, h) return pointH @@ -430,6 +435,7 @@ class EllipsoidTriaxial: x = self.ax * np.cos(u) * np.cos(v) y = self.ay * np.cos(u) * np.sin(v) z = self.b * np.sin(u) + z = np.broadcast_to(z, np.shape(x)) return np.array([x, y, z]) def cart2para(self, point: np.ndarray) -> tuple[float, float]: @@ -457,6 +463,26 @@ class EllipsoidTriaxial: return u, v + def ell2para(self, beta, lamb) -> tuple[float, float]: + cart = self.ell2cart(beta, lamb) + return self.cart2para(cart) + + def para2ell(self, u, v) -> 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]: + cart = self.para2cart(u, v) + return self.cart2geod(cart, mode, maxIter, maxLoa) + + def geod2para(self, phi, lamb, h) -> tuple[float, float]: + cart = self.geod2cart(phi, lamb, h) + return self.cart2para(cart) + + def ell2geod(self, beta, lamb, 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 func_H(self, x, y, z): return x ** 2 + y ** 2 / (1 - self.ee ** 2) ** 2 + z ** 2 / (1 - self.ex ** 2) ** 2 @@ -523,19 +549,20 @@ if __name__ == "__main__": cart_para = ell.para2cart(para[0], para[1]) diff_para = np.sum(np.abs(point-cart_para)) - geod = ell.cart2geod("ligas1", point) - cart_geod = ell.geod2cart(geod[0], geod[1], geod[2]) - diff_geod1 = np.sum(np.abs(point-cart_geod)) + # geod = ell.cart2geod(point, "ligas1") + # cart_geod = ell.geod2cart(geod[0], geod[1], geod[2]) + # diff_geod1 = np.sum(np.abs(point-cart_geod)) + # + # geod = ell.cart2geod(point, "ligas2") + # cart_geod = ell.geod2cart(geod[0], geod[1], geod[2]) + # diff_geod2 = np.sum(np.abs(point-cart_geod)) - geod = ell.cart2geod("ligas2", point) - cart_geod = ell.geod2cart(geod[0], geod[1], geod[2]) - diff_geod2 = np.sum(np.abs(point-cart_geod)) - - geod = ell.cart2geod("ligas3", point) + geod = ell.cart2geod(point, "ligas3") cart_geod = ell.geod2cart(geod[0], geod[1], geod[2]) diff_geod3 = np.sum(np.abs(point-cart_geod)) - diff_list.append([beta_deg, lamb_deg, diff_ell, diff_para, diff_geod1, diff_geod2, diff_geod3]) + diff_list.append([beta_deg, lamb_deg, diff_ell, diff_para, diff_geod3]) + diff_list.append([diff_ell]) diff_list = np.array(diff_list) pass \ No newline at end of file diff --git a/show_constant_lines.py b/show_constant_lines.py new file mode 100644 index 0000000..d20c6e6 --- /dev/null +++ b/show_constant_lines.py @@ -0,0 +1,30 @@ +import numpy as np +import plotly.graph_objects as go +from ellipsoide import EllipsoidTriaxial +import winkelumrechnungen as wu +from dashboard import ellipsoid_figure + +u = np.linspace(0, 2*np.pi, 51) +v = np.linspace(0, np.pi, 51) +ell = EllipsoidTriaxial.init_name("BursaSima1980round") +points = [] +lines = [] +for u_i, u_value in enumerate(u): + for v_i, v_value in enumerate(v): + cart = ell.ell2cart(u_value, v_value) + if u_i != 0 and v_i != 0: + lines.append((points[-1], cart, "red")) + points.append(cart) +points = [] +for v_i, v_value in enumerate(v): + for u_i, u_value in enumerate(u): + cart = ell.ell2cart(u_value, v_value) + if u_i != 0 and v_i != 0: + lines.append((points[-1], cart, "blue")) + points.append(cart) +ax = ell.ax +ay = ell.ay +b = ell.b + +figu = ellipsoid_figure(ax, ay, b, lines=lines) +figu.show() \ No newline at end of file