# Angular distance calculation in Equatorial and Galactic coordinates

I calculated the angular distance between the Galactic Center and Andromeda in Equatorial and Galactic coordinates and observed that the distance is calculated differently depending on the coordinate system.

In Equatorial coordinates their locations are

Galactic Center
Ra 271.087458 degrees
Dec -29.519139 degrees
Andromeda
Ra 00h 42m 44.3s  (10.6845833 degrees)
Dec +41° 16′ 9″   (41.2691667 degrees)


In Galactic Coordinates

Galactic Center
latitude 0.0
longitude 0.0
Andromeda
latitude 121.174329
longitude -21.573309


This is my Python codes for calculating the distance.

import numpy as np

def get_psi(Ra1, Dec1, Ra2, Dec2):
psi = np.arccos(np.sin(Dec1)*np.sin(Dec2) \
+ np.cos(Dec1)*np.cos(Dec2)\
* np.cos(Ra1-Ra2))
return psi

psi_GC_to_M31 = get_psi(GC_ra, GC_dec, M31_ra, M31_dec)
print(np.degrees(psi_GC_to_M31))


The results are

115.72397726560764
118.77568027887287


Why would the values differ by 3 degrees?

• @stretch The law of cosines in the posting above would be correct. See en.wikipedia.org/wiki/Angular_distance Jun 11 at 23:46
• @stretch I got the galactic coordinates of Andromeda from SIMBAD and added it to the question. Jun 11 at 23:51
• There’s probably an error in your coordinates. Using 2023.4 (current) coordinates, I get the same angular distance between the two, in both equatorial and galactic coordinates. What is the source of your coordinates for the galactic center? Jun 12 at 1:23
• @Nownuri your formula is correct - at a glance it looks wrong. Jun 13 at 15:53

(1) Distance between 2 points, knowing their equatorial coordinates:

Galactic Center:

Note that $$\alpha_1=271.087458^o$$ and $$\delta_1=-29.519139^o$$ are not correct values. According Galactic coordinate system the correct values referred to J2000 are:

$$\alpha_1=17^h \ 45^m \ 37.22^s=266.4051^o$$

$$\delta_1=-28^o \ 56' \ 10.23''=-28.936175^o$$

Andromeda galaxy (M31)

$$\alpha_2=00^h \ 42^m \ 44.3^s=10.6845833^o$$

$$\delta_2=+41^0 \ 16' \ 09''=+41.2691667^o$$

Distance:

$$d=\arccos \Big [ \sin \delta_1 \sin \delta_2 + \cos \delta_1 \cos \delta_2 \cos (\alpha_1-\alpha_2) \Big ]$$

$$\boxed{d=118.775612^o}$$

(2) Distance between 2 points, knowing their galactic coordinates:

Galactic Center:

Galactic Longitude $$l_1=0^o$$

Galactic Latitude $$b_1=0^o$$

Andromeda galaxy (M31)

Galactic Longitude is not $$l_2=-21.573309^o$$ is $$l_2=121.174329^o$$

Galactic Latitude is not $$b_2=121.174329^o$$ is $$b_2=-21.573309^o$$

Distance:

$$d=\arccos \Big [ \sin b_1 \sin b_2 + \cos b_1 \cos b_2 \cos (l_1-l_2) \Big ]$$

$$\boxed{d=118.775680^o}$$

Perhaps it might be interesting to browse the thread: How can I convert my sky coordinate system (RA, Dec) into galactic coordinate system (l, b)?

Best regards.