# Convert Between Rectangular And Polar Coordinates

Polar to Rectangular: \begin{align*} x& = r \sin \theta \cos \varphi \\ y& = r \sin \theta \sin \varphi \\ z& = r \cos \theta \\ \end{align*} Rectangular to Polar: \begin{align*} r& = \sqrt{x^2 + y^2 + z^2} \\ \cos \theta& = \frac{z}{r} \\ \cos \varphi& = \frac{x}{\sqrt{x^2 + y^2}} \\ \sin \varphi& = \frac{y}{\sqrt{x^2 + y^2}} \\ \tan \varphi& = \frac{y}{x} \\ \end{align*}
• x is Horizontal (left and right).
• y is Depth (in and out of screen).
• z is Vertical (up and down).
• $$\theta$$ Vertical (usually lattitude or declination). Range -90° to 90°.
• $$\varphi$$ Horizontal (usually longitude or right ascension). Range -180° to 180°, or 0° to 360°
• $$r$$ Radius.