StringMash.com

Cartesian to spherical and cylindrical

3D points in (x, y, z), (r, θ, φ) and (ρ, φ, z), with the working shown.

Conversion
9 characters
Updates as you type

Show the steps
  1. r = √(x² + y² + z²) = √(1² + 1² + 1²) = 1.7321
  2. θ = cos⁻¹(z / r) = cos⁻¹(1 / 1.7321) = 54.7356°, measured down from the +z axis.
  3. φ = atan2(y, x) = atan2(1, 1) = 45°, measured from the +x axis.
  4. Written in the order r, θ, φ (θ from the z axis, φ the azimuth).

Using the converter

Type three numbers, x, y and z, and pick the system from the menu. Spherical coordinates come back as r and two angles; cylindrical as ρ, an angle and z. Swap turns either one back into Cartesian.

The Convention setting matters for spherical coordinates. Physics books and the ISO 80000-2 standard call the angle down from the z axis θ and the angle round from the x axis φ. Many maths books swap the two letters. The numbers are the same; only the names and their order change.

Spherical coordinates

r is the straight-line distance from the origin: √(x² + y² + z²). In the ISO convention, θ is the angle down from the +z axis, cos⁻¹(z / r), between 0° and 180°. φ is the angle round from the +x axis in the xy plane, atan2(y, x), as in 2D polar coordinates.

Going back, x = r sin θ cos φ, y = r sin θ sin φ and z = r cos θ. For (1, 1, 1), r = √3 ≈ 1.7321, θ ≈ 54.7356° and φ = 45°.

Cylindrical coordinates

Cylindrical coordinates are polar coordinates with the height left alone. ρ = √(x² + y²) is the distance from the z axis, φ = atan2(y, x) is the angle round it, and z stays as it is. (3, 4, 5) becomes ρ = 5, φ ≈ 53.1301°, z = 5.

They suit anything shaped like a pipe, a coil or a can, where the distance from the axis matters more than the distance from a point.

Latitude and longitude

A globe is spherical coordinates with different habits. Longitude is φ, measured from Greenwich instead of an x axis. Latitude is measured up from the equator, not down from the pole, so latitude is 90° − θ: the North Pole is θ = 0° and latitude 90°. Real GPS coordinates also allow for the Earth not being a perfect sphere, which is why the GPS coordinate converter and projection tools use the WGS84 ellipsoid instead.

Questions

Which angle is θ in spherical coordinates?

In physics and ISO 80000-2, θ is the angle from the +z axis and φ the angle round from +x. Many maths textbooks swap them. Set the Convention to match your book.

What are (1, 1, 1) in spherical coordinates?

r = √3 ≈ 1.7321, θ ≈ 54.7356° from the z axis, and φ = 45°.

What's the difference between ρ and r?

In cylindrical coordinates ρ is the distance from the z axis. In spherical coordinates r is the distance from the origin. For a point in the xy plane they're equal.

What happens on the z axis?

x and y are both 0, so the angle round the axis could be anything. The converter gives it as 0 and says so.

Sources

Added . What's new