# Figure out the location of celestial objects relative to the Milky Way in x, y, z co-ordinates

I am trying to place various celestial objects the correct distance from the Milky Way, using x, y, z co-ordinates. So assuming the centre-of-mass of the Milky Way is at 0, 0, 0 - how can I figure out where to place a galaxy or star given it's celestial coordinates?

I'm just an amateur, and pushing 60 years old, so please excuse me if I have something wrong here...

• Which directions have you decided on for the x,y,and z axes? Sep 22, 2020 at 12:43
• I'm not sure - I don't know what would make most sense.
– Andy
Sep 22, 2020 at 12:48
• Most sense makes to place Andromeda exactly in x direction. Unless you have other constraints. Every coordinate system is arbitrary and chosen to be most useful to compare places. You can even place Andromeda at (1,0,0) and say your unit of length is in distances of the separation of milky-way and Andromeda Sep 22, 2020 at 15:19
• If you can Python a little bit, or would like to learn, have a look at this answer. Skyfield will do the math for you, and a lot of other fun things as well.
– uhoh
Sep 23, 2020 at 12:14

The spherical $$(r, l, b)$$ can be converted to rectangular $$(U, V, W)$$ as:

\begin{align} U &= r \cos b \cos l \\ V &= r \cos b \sin l \\ W &= r \sin b \end{align}

Using $$(r, l, b) = (770 \pm 40 ~\text{kpc}, 121.2^\circ, -21.6^\circ)$$,

\begin{align} U &= -371 \mp 19 ~\text{kpc} \\ V &= ~~~ 612 \pm 32 ~\text{kpc} \\ W &= -283 \mp 15 ~\text{kpc} \end{align}

That's relative to the Sun. For a position relative to the center of our galaxy, subtract $$8 \pm 0.5 ~\text{kpc}$$ from $$U$$.

• But isn't Andromeda at 121.2 degrees longitude, and -21.6 degrees latitude based on the centre of the Milky Way? rather than from Earth or the Sun?
– Andy
Sep 23, 2020 at 4:32
• Maybe it's easier to assume the we're in the centre of the Milky Way (at 0,0,0), it's disk is flat, and now I want to place Andromeda at the correct x,y,z location and distance.
– Andy
Sep 23, 2020 at 4:33
• @Andy The center of the Milky Way is at (lon, lat) = (0, 0) in conventional Sun-centered galactic coords. The conversion to galaxy-centered coords is a translation along the U axis. Sep 23, 2020 at 19:24