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

Possibly incorrect results of keplerian_to_cartesian #235

Open
gaowutong opened this issue Jan 16, 2025 · 3 comments
Open

Possibly incorrect results of keplerian_to_cartesian #235

gaowutong opened this issue Jan 16, 2025 · 3 comments

Comments

@gaowutong
Copy link

In the AstrodynamicalCalculations library, the keplerian_to_cartesian function appears to produce incorrect results.

Here's a simple test: Take any valid state vector and its corresponding GM value, convert to orbital elements using cartesian_to_keplerian, then convert back using keplerian_to_cartesian. The resulting state vector does not match the original.

Test code:

rv = [6878.137, 10, 10, 0, 7.612, 0]
mu = 398600.4415
println(collect(keplerian_to_cartesian(cartesian_to_keplerian(rv..., mu)..., mu)) - rv)

Output:

[-9.094947017729282e-13, 6838.04881967674, -2.341273841466318e-10, 1.3768591025695304e-15, 2.6645352591003757e-15, 2.1487788277296093e-20]
@gaowutong
Copy link
Author

The problem is possibly due to the incorrectness of perifocal_to_cartesian:

R_3Ω = SMatrix{3,3}(cos(Ω), sin(Ω), 0, -sin(Ω), cos(ω), 0, 0, 0, 1)

cos(ω) should be cos(Ω).

@cadojo
Copy link
Collaborator

cadojo commented Jan 19, 2025

Great find, thank you! If you wanted to add that change as a PR, that would be really appreciated. If not, I can add this change this week.

@gaowutong
Copy link
Author

I'm not familiar with the project branch, you can add it directly ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants