# Get (X, Y, Z) coordinates from Horizontal Coordinates

I'm developing a planetarium software using the Hipparcos Catalogue. I have also implemented all the formulas of the book: "Practical astronomy with your Calculator and Spreadsheet".

With these formulas, I'm trying to draw the star inside a 3D space using its Horizontal Coordinates. To do it, I'm using these calculations to get its X, Y and Z coordinates:

$$X = \cos(Azimuth)$$ $$Y = \cos(Altitude)$$ $$Z = \sin(Altitude)$$

I'm trying to get the coordinate of point X in this image:

$$a$$ is altitude.
$$A$$ is azimuth.

$$Azimuth$$ and $$Altitude$$ are in decimal degrees.

Maybe, I have to use it in radians, or maybe it is the sine instead of cosine. Anyway, this is what I get:

The stars aren't drawn as a sphere.

How can I fix this problem?

• I can't tell from your question what you are trying to do. Almost all computer languages expect the arguments of trigonometry functions to be in radians though. Feb 18, 2023 at 8:32
• Your equations don't make sense. And you didn't tell us what convention you're using for X, Y, Z. Have you seen en.wikipedia.org/wiki/Spherical_coordinate_system ? Feb 18, 2023 at 8:42
• I have updated my question. Feb 18, 2023 at 9:05

Using the notation in your diagram.

$$x = \cos (a) \cos (A)$$ $$y = \cos (a) \sin (A)$$ $$z = \sin (a)$$

In most computer codes, all the angles should be in radians, where $$\theta_{\rm rad} = \theta_{\rm deg} \times \pi/180$$.

Note that if comparing with other sources, you do have to pay attention to how the angles are defined. For instance, the altitude is $$90^{\circ} -$$ the usual polar angle in spherical polar coordinates.

• I think it is $x = \sin (a) \cos (A)$ and $y = \sin (a) \sin (A)$. At least, this is how this formula appears in my Calculus book (and also in Wikipedia). Mar 17, 2023 at 19:55
• @VansFannel I don't think so. Mar 17, 2023 at 23:33
• Well, you can believe whatever you want. Just look it up on Wikipedia and check what I say. Mar 19, 2023 at 15:12
• @VansFannel put the link here and I might. You might be confused with polar coordinates, where the expression would be $x = \sin\theta \cos\phi$ etc Mar 19, 2023 at 15:29
• @VansFannel both of those sources are in perfect agreement with my answer. You DO have to pay attention to how the angles are defined. Mar 26, 2023 at 9:34