Algorithmen Test
This commit is contained in:
@@ -327,14 +327,45 @@ class EllipsoidTriaxial:
|
||||
x, y, z = point
|
||||
beta, lamb = self.cart2ell_panou(point)
|
||||
delta_ell = np.array([np.inf, np.inf]).T
|
||||
tiny = 1e-30
|
||||
|
||||
i = 0
|
||||
while np.sum(delta_ell) > eps and i < maxI:
|
||||
while np.linalg.norm(delta_ell) > eps and i < maxI:
|
||||
if abs(y) < eps:
|
||||
delta_y = 1e-4
|
||||
best_delta = np.inf
|
||||
while True:
|
||||
try:
|
||||
y1 = y - delta_y
|
||||
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]))
|
||||
point1 = self.ell2cart(beta1, lamb1)
|
||||
|
||||
y2 = y + delta_y
|
||||
beta2, lamb2 = self.cart2ell(np.array([x, y2, z]))
|
||||
point2 = self.ell2cart(beta2, lamb2)
|
||||
|
||||
pointM = (point1 + point2) / 2
|
||||
|
||||
actual_delta = np.linalg.norm(point-pointM)
|
||||
except:
|
||||
actual_delta = np.inf
|
||||
|
||||
if actual_delta < best_delta:
|
||||
best_delta = actual_delta
|
||||
delta_y /= 10
|
||||
else:
|
||||
delta_y *= 10
|
||||
|
||||
y1 = y - delta_y
|
||||
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]))
|
||||
|
||||
return beta1, lamb1
|
||||
|
||||
x0, y0, z0 = self.ell2cart(beta, lamb)
|
||||
delta_l = np.array([x-x0, y-y0, z-z0]).T
|
||||
|
||||
B = self.Ex ** 2 * cos(beta) ** 2 + self.Ee ** 2 * sin(beta) ** 2
|
||||
L = self.Ex ** 2 - self.Ee ** 2 * cos(lamb) ** 2
|
||||
B = max(self.Ex ** 2 * cos(beta) ** 2 + self.Ee ** 2 * sin(beta) ** 2, tiny)
|
||||
L = max(self.Ex ** 2 - self.Ee ** 2 * cos(lamb) ** 2, tiny)
|
||||
|
||||
J = np.array([[(-self.ax * self.Ey ** 2) / (2 * self.Ex) * sin(2 * beta) / sqrt(B) * cos(lamb),
|
||||
-self.ax / self.Ex * sqrt(B) * sin(lamb)],
|
||||
@@ -345,23 +376,21 @@ class EllipsoidTriaxial:
|
||||
|
||||
N = J.T @ J
|
||||
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]]])
|
||||
delta_ell = N_inv @ J.T @ delta_l
|
||||
|
||||
beta += delta_ell[0]
|
||||
lamb += delta_ell[1]
|
||||
i += 1
|
||||
|
||||
if i == maxI:
|
||||
raise Exception("Umrechung ist nicht konvergiert")
|
||||
raise Exception("Umrechnung ist nicht konvergiert")
|
||||
|
||||
point_n = self.ell2cart(beta, lamb)
|
||||
delta_r = np.linalg.norm(point - point_n, axis=-1)
|
||||
|
||||
if delta_r > 1e-4:
|
||||
# raise Exception("Fehler in der Umrechnung cart2ell")
|
||||
print(f"Fehler in der Umrechnung cart2ell, deltaR = {delta_r}m")
|
||||
if delta_r > 1e-3:
|
||||
raise Exception("Fehler in der Umrechnung cart2ell")
|
||||
|
||||
return beta, lamb
|
||||
|
||||
@@ -395,9 +424,9 @@ class EllipsoidTriaxial:
|
||||
t1, t2 = self.func_t12(point)
|
||||
|
||||
num_beta = max(t1 - self.b ** 2, 0)
|
||||
den_beta = max(self.ay ** 2 - t1, 0)
|
||||
den_beta = max(self.ay ** 2 - t1, 1e-30)
|
||||
num_lamb = max(t2 - self.ay ** 2, 0)
|
||||
den_lamb = max(self.ax ** 2 - t2, 0)
|
||||
den_lamb = max(self.ax ** 2 - t2, 1e-30)
|
||||
|
||||
beta = arctan(sqrt(num_beta / den_beta))
|
||||
lamb = arctan(sqrt(num_lamb / den_lamb))
|
||||
@@ -675,7 +704,7 @@ class EllipsoidTriaxial:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ell = EllipsoidTriaxial.init_name("BursaSima1980round")
|
||||
ell = EllipsoidTriaxial.init_name("BursaSima1980")
|
||||
diff_list = []
|
||||
diffs_para = []
|
||||
diffs_ell = []
|
||||
@@ -711,6 +740,7 @@ if __name__ == "__main__":
|
||||
diffs_geod = np.array(diffs_geod)
|
||||
|
||||
pass
|
||||
|
||||
points = np.array(points)
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(projection='3d')
|
||||
|
||||
Reference in New Issue
Block a user