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: enter image description here

$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:

enter image description here

The stars aren't drawn as a sphere.

How can I fix this problem?

  • 1
    $\begingroup$ 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. $\endgroup$
    – ProfRob
    Feb 18, 2023 at 8:32
  • $\begingroup$ 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 ? $\endgroup$
    – PM 2Ring
    Feb 18, 2023 at 8:42
  • $\begingroup$ I have updated my question. $\endgroup$
    – VansFannel
    Feb 18, 2023 at 9:05

1 Answer 1


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.

  • $\begingroup$ 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). $\endgroup$
    – VansFannel
    Mar 17, 2023 at 19:55
  • $\begingroup$ @VansFannel I don't think so. $\endgroup$
    – ProfRob
    Mar 17, 2023 at 23:33
  • $\begingroup$ Well, you can believe whatever you want. Just look it up on Wikipedia and check what I say. $\endgroup$
    – VansFannel
    Mar 19, 2023 at 15:12
  • $\begingroup$ @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 $\endgroup$
    – ProfRob
    Mar 19, 2023 at 15:29
  • 3
    $\begingroup$ @VansFannel both of those sources are in perfect agreement with my answer. You DO have to pay attention to how the angles are defined. $\endgroup$
    – ProfRob
    Mar 26, 2023 at 9:34

You must log in to answer this question.

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