Skip to content

Distance from Earth to other solar system bodies. #361

Answered by cosinekitty
Tichro asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Tichro and welcome to the project! You can use the geoVector function to calculate a 3D vector from the center of the Earth to the center of a planet, the Sun, or the Moon. Then you can use the length member function to find the distance expressed in astronomical units:

Vector vec = Astronomy.geoVector(Body.Jupiter, time, Aberration.Corrected);
double dist = vec.length();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Tichro
Comment options

Answer selected by Tichro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants