1
$\begingroup$

I'm following the steps in this paper on how to calculate geocentric longitude. In section 3.4.2 it says the

Geocentric rectangular co-ordinates of Mercury then are:

Xg = Xh−X0 = 0.990 A.U.
Yg = Yh−Y0 = −0.259 A.U.

Converting these into polar form, we get the geocentric distance and longitude as:

rg = √(X2g+Y2g) = 1.024 A.U.
λg = tan−1(Yg/Xg) = 345.3◦.

For the life of me I cannot get the inverse tan of (Yg/Xg) to give me 345.3. This is what I'm doing in python:

Xg= 0.990 
Yg= -0.259 
math.degrees(math.atan(Yg/Xg)) = -14.66091789971255

Any help greatly appreciated.

$\endgroup$

2 Answers 2

3
$\begingroup$

You miss the simple fact that a circle is 360° periodic. Your result is correct:

360°-14.66° = 345.34°.

Thus you miss that the arctan usually returns -180...+180° and you don't correct for the fact that the longitude is positive defined in the range of 0 ... 360°. Thus add +360° when your result is negative.

$\endgroup$
3
$\begingroup$

You should be using the two argument version of arctan, math.atan2(y, x), to ensure that the result is in the correct quadrant. But in this case math.atan2(y, x) will return the same value as math.atan(y/x). -14.66° is the equivalent to 345.34°.

$\endgroup$
2
  • 1
    $\begingroup$ Noted thank you! $\endgroup$
    – skiventist
    Jun 23, 2020 at 10:52
  • 1
    $\begingroup$ @skiventist atan2 is almost always a better choice than plain atan. And it properly handles the case when x=0. $\endgroup$
    – PM 2Ring
    Jun 23, 2020 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .