For my application I need to calculate an angle between two different lines:
1) The first line is between a point on the earth which is defined by longitude and latitude and the center of the sun.
2) The second line is between a point on the earth which is defined by longitude and latitude and the surface on the moon with the smalles distance from the earth.
I have no idea how I should start there. Any hints?
Assuming that you've actually got all three points of interest calculated already[*], where O
is the position of the observer (on Earth), S
is the position of the Sun and M
is the point on the Moon, then:
OM . OS = |OM| * |OS| * cos(theta)
Or, in other words, to calculate theta
, take the dot product of the two vectors, divide that result by the magnitude of those two vectors, and then take the inverse cosine of the result.
[*] your question only asks for the angle between two lines - if instead you want to know how to calculate the actual lines for any moment in time then you should rewrite your question.
Well first of all, the questions is at what point in time. Moon revolves around the earth which in turn revolves around the sun so the distances and angles you mention are different at different point in time.
For example when you have an eclipse the angle is close to zero.
So without the information of time and exact knowledge of earths, moons and suns position at that given time the calculation is impossible.
You might want to dig through the sources of Celestia to look for equations that would let you determine the position of the point on the earth in relation to center of the moon and sun.
When you have those coordinates apply Alnitak's suggestion on vector dot products
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With