Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the angle between a place on Earth and the Sun?

Tags:

java

algorithm

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?

like image 780
RoflcoptrException Avatar asked Mar 17 '11 11:03

RoflcoptrException


3 Answers

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.

like image 108
Alnitak Avatar answered Oct 19 '22 07:10

Alnitak


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.

like image 1
Filip Kis Avatar answered Oct 19 '22 05:10

Filip Kis


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

like image 1
Unreason Avatar answered Oct 19 '22 05:10

Unreason