# Spherical Coordinates Calculator

The spherical coordinates calculator is a tool that converts between rectangular and spherical coordinate systems. It describes the position of a point in a three-dimensional space, similarly as our cylindrical coordinates calculator. For a two-dimensional space, instead of using this Cartesian to spherical converter, you should head to the polar coordinates calculator.

## Rectangular and spherical coordinates

Coordinates are sets of values that describe the position of any given point in space. For a three-dimensional space, you need exactly three coordinates to uniquely define a point.

The Cartesian system, also known as the rectangular coordinate system, is constructed by drawing three lines in space. They all cross a common point, called the **origin**, and are perpendicular to one another. These lines are called the **axes** of the system. Each pair of axes defines a plane: these are called the XY, XZ and YZ planes. The coordinates of any arbitrary point are defined as the distance between that point and the planes.

Spherical coordinate system is defined by a fixed **origin** and a **zenith direction**. The zenith is an imaginary point located directly above the origin. The direction from the origin to zenith is called the zenith direction.

Each arbitrary point in space has three spherical coordinates. The first one, called **radial distance** or **radius** (**r**), is simply the three-dimensional distance between the origin and this point. The second one - the **polar angle** (**θ**) - is the angle from the zenith direction to the line that connects the point with the origin. The third one is called the **azimuth angle** (**φ**). When you create a reference plane that passes through the origin and is orthogonal to the zenith, then φ is the angle between the point's orthogonal projection to the plane and a fixed reference direction on that plane.

## Converting Cartesian to spherical

When converting from the rectangular to the spherical system, our spherical coordinate calculator assumes that the origins of both systems overlap. It also assumes that the z-axis is equivalent to the zenith direction. The spherical reference plane coincides with the XY plane.

You should use the following formulas for the conversion:

`r = √(x² + y² + z²)`

`θ = arccos (z/r)`

`φ = arctan (y/x)`

where:

- (x, y, z) are the Cartesian coordinates, and
- (r, θ, φ) are the spherical coordinates.

## Converting spherical to Cartesian

The spherical coordinates calculator is also able to recalculate the spherical coordinates into rectangular ones. It uses the following equations:

`x = r * sinθ * cosφ`

`y = r * sinθ * sinφ`

`z = r * cosθ`