<p>The spherical <span class="math-container">$(r, l, b)$</span> can be converted to
<a href="https://en.wikipedia.org/wiki/Galactic_coordinate_system#Rectangular_coordinates" rel="nofollow noreferrer">rectangular</a>
<span class="math-container">$(U, V, W)$</span> as:</p>
<p><span class="math-container">$$\begin{align}
U &amp;= r \cos b \cos l \\
V &amp;= r \cos b \sin l \\
W &amp;= r \sin b
\end{align}$$</span></p>
<p>Using <span class="math-container">$(r, l, b) = (770 \pm 40 ~\text{kpc}, 121.2^\circ, -21.6^\circ)$</span>,</p>
<p><span class="math-container">$$\begin{align}
U &amp;= -371 \mp 19 ~\text{kpc} \\
V &amp;= ~~~ 612 \pm 32 ~\text{kpc} \\
W &amp;= -283 \mp 15 ~\text{kpc}
\end{align}$$</span></p>
<p>That's relative to the Sun.
For a position relative to the center of our galaxy,
subtract <span class="math-container">$8 \pm 0.5 ~\text{kpc}$</span> from <span class="math-container">$U$</span>.</p>

CC BY-SA 4.0
2020-09-23T04:32:00.067Z
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
CC BY-SA 4.0
2020-09-23T04:33:19.767Z
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
CC BY-SA 4.0
2020-09-23T19:24:40.117Z
@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.
Mike G
CC BY-SA 4.0
2020-09-22T16:31:13.127Z
2020-09-22T16:31:13.127Z
Mike G
<p>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?</p>
<p>I'm just an amateur, and pushing 60 years old, so please excuse me if I have something wrong here...</p>

CC BY-SA 4.0
2020-09-22T12:43:26.327Z
Which directions have you decided on for the x,y,and z axes?
notovny
CC BY-SA 4.0
2020-09-22T12:48:15.393Z
I'm not sure - I don't know what would make most sense.
Andy
CC BY-SA 4.0
2020-09-22T15:19:07.590Z
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
planetmaker
CC BY-SA 4.0
2020-09-23T12:14:06.143Z
If you can Python a little bit, or would like to learn, have a look at [this answer](https://astronomy.stackexchange.com/a/23924/7982).  Skyfield will do the math for you, and a lot of other fun things as well.
uhoh
<coordinate><galactic-dynamics>
Figure out the location of celestial objects relative to the Milky Way in x, y, z co-ordinates
Andy
# Figure out the location of celestial objects relative to the Milky Way in x, y, z co-ordinates

(Asked by: username_0 on 2020-09-22)

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...

**Tags:** coordinate, galactic-dynamics

> **Comments:**
> **username_1**: Which directions have you decided on for the x,y,and z axes?  
> **username_0**: I'm not sure - I don't know what would make most sense.  
> **username_2**: 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  
> **username_3**: If you can Python a little bit, or would like to learn, have a look at [this answer](https://astronomy.stackexchange.com/a/23924/7982).  Skyfield will do the math for you, and a lot of other fun things as well.  

---

## 1 answers

### Answer by username_4 on 2020-09-22. Score: 3

The spherical $(r, l, b)$ can be converted to
[rectangular](https://en.wikipedia.org/wiki/Galactic_coordinate_system#Rectangular_coordinates)
$(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$.

> **Comments:**
> **username_0**: 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?  
> **username_0**: 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.  
> **username_4**: @username_0 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.  

---

