I'm using the Galactic Coordinates to draw stars in a 3D space, but I don't know how to do it.

In the book "Practical Astronomy with your Calculator or Spreadsheet" I've found this:

enter image description here

S: the Sun.
G: the centre of the Galaxy.
X: a star which not lie in the galactic plane.
l: galactic longitude.
b: galactic latitude.

If I know S, G, l and b. How can I know the (x, y, z) coordinates of the star X?

Probably I need to know the distance between S and X.

  • $\begingroup$ Yes, you will indeed need to know the distance between S and X. Multiple star catalogues are available on the Internet which can provide you with this information. Keep in mind, though, that astronomical distances can only be measured indirectly, and there is an error margin to the measurement, so you may get slightly different values in different catalogues. $\endgroup$ Commented Mar 27, 2023 at 2:43
  • 1
    $\begingroup$ You can use the "parallax" field of a star catalog, and the RA/Dec to compute the XYZ coordinates relative to the Solar System Barycenter. Example is here: celestialprogramming.com/snippets/starxyz.html . Then shift the results so the galactic center is 0,0,0. $\endgroup$ Commented Mar 27, 2023 at 5:08
  • $\begingroup$ @GregMiller Thanks for you comment. Now, I'm using Hipparcos Catalogue, but I've been checking the Gaia project to look for a field called "distance". $\endgroup$
    – VansFannel
    Commented Mar 27, 2023 at 7:06

1 Answer 1


You can't without knowing the distance to the star, $d$.

Once you have that then, depending on exactly how the $x, y, z$ axes are defined: $$ \begin{align} x &= d \cos(b)\cos(l) \\ y &= d \cos(b) \sin(l) \\ z &= d \sin(b)\ , \end{align} $$ where I have used a usual convention that $x$ is measured towards the Galactic centre from Earth, $y$ is measured at right angles to this but in the Galactic plane and $z$ is perpendicular to the Galactic plane.

If you wish to have the origin at the Galactic centre then simply subtract the $x$ coordinate of the Galactic centre from $x$.

Where might you find those distances? Well, you haven't said what stars you are trying to find the positions of. A good source of parallax data for roughly a billion stars is the Gaia DR3 catalogue. The parallaxes can be transformed to a distance (an approach to this is provided by the catalogue of Bailer-Jones 2021). If you are just working with stars in the Hipparcos catalogue, then that catalogue also contains (less precise) parallaxes, the reciprocal of which gives an approximate value of the distance.


You must log in to answer this question.

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