Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formular is not accurate enough #4

Open
miniufo opened this issue Jun 21, 2024 · 0 comments
Open

formular is not accurate enough #4

miniufo opened this issue Jun 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@miniufo
Copy link
Owner

miniufo commented Jun 21, 2024

Just find out that the formular used to get the lat/lon coordinates from cylindrical coordinates is not accurate enough. The formula are:

$$\begin{align} \phi &= \arcsin(\sin\phi_o\cos\beta + \cos\phi_o\sin\beta\cos\alpha) \\\ \lambda_o-\lambda &= \arcsin(\sin\beta\sin\alpha / \cos\phi) \end{align}$$

where ($\alpha$, $\beta$) are the cylindrical coordinates, ($\lambda$, $\phi$) are the spherical polar coordinates, subscript o indicates the point at the center of the cylindrical coordinate.

The original codes here used a wrong formula:

$$\begin{align} \lambda_o-\lambda &= \arcsin(\sin\beta\sin\alpha) / \cos\phi \end{align}$$

It is interesting that this wrong formula gives approximately the correct results. This can be verified by:

import numpy as np

a1, a2, a3 = np.random.rand(3)*2-1
print(a1, a2, a3)
print('original')
print(np.arcsin(a1*a2/a3))
print(np.arcsin(a1*a2)/a3)
print('reduce a1 or a2')
a1 = a1 / 10
print(np.arcsin(a1*a2/a3))
print(np.arcsin(a1*a2)/a3)

which gives for example:

0.8287575472998463 0.20858890514091422 -0.35868636289313427
original
-0.5028812207377986
-0.48438535604941
reduce a1 or a2
-0.048213882743891996
-0.04819760618048353

This means that when radial angle $\beta$ is small, these two formula are close to each other. This is why I didn't notice this bug here. Now it will be corrected.

@miniufo miniufo added the bug Something isn't working label Jun 21, 2024
@miniufo miniufo self-assigned this Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant