EN

Spherical ↔ Cartesian Coordinates Converter

The same point in space can be described either by its Cartesian coordinates (x, y, z), or by its spherical coordinates: the radius r (distance to the origin), the polar angle θ (measured from the +z axis) and the azimuth φ (measured from the +x axis in the xy plane). This tool switches between the two.

Physics convention used here: θ is the colatitude (0 at the north pole +z, π/2 in the xy plane). In the mathematics convention, the roles of θ and φ are often swapped.

Conversion

Direction and units
Cartesian → spherical

Result

  • Radius r 1.73 m
Radius r1.73 m
Polar angle θ (from +z)54.74 °
Azimuth φ (from +x)45.00 °

r = √(x²+y²+z²), θ = arccos(z/r), φ = atan2(y, x)

The glossary at the foot of the page explains starred terms.

Physics convention: r, θ (polar angle), φ (azimuth)

One point in space, two common address books. Cartesian: (x, y, z). Spherical, in the convention used here — the physics convention — three numbers:

  • r ≥ 0, distance from the origin.
  • θ, the polar angle or colatitude*, measured from the +z axis. 0 at the “north pole”, π/2 in the xy-plane, π at the “south pole”.
  • φ, the azimuth*, measured from +x in the xy-plane, 0 to 2π, toward +y.

θ is not a latitude. φ is not a geographic longitude (that one starts at a meridian, often Greenwich, and may be signed east/west). Here there is an orthonormal frame, a pole +z, an origin. That is the whole stage.

ISO 80000-2 writes the same trio (r, θ, φ) this way. Older physics books do too. The converter on this page follows that standard, not the swapped-letter habit of some calculus texts.

Spherical to Cartesian

The radius is projected. Its z-component is r cos θ. What remains, r sin θ, lies in the xy-plane and splits according to φ.

x = r · sin θ · cos φ  ·  y = r · sin θ · sin φ  ·  z = r · cos θ

θ = 0, sin θ = 0, x = y = 0, z = r: the north pole. θ = π/2, z = 0: the point sits in the xy-plane, at distance r, at azimuth φ. φ = 0, y = 0, x = r sin θ: the half-plane of positive x. A triple (r, θ, φ) maps to exactly one (x, y, z).

At bottom this is polar coordinates in the plane, with one extra layer. The polar pair in xy is (ρ, φ) with ρ = r sin θ. Cylindrical coordinates (ρ, φ, z) sit halfway between Cartesian and spherical; z = r cos θ stitches the two.

Cartesian to spherical, and why atan2 matters

The inverse is unique for r, almost unique for θ, and fussy for φ.

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

θ = arccos(z / r)  (r > 0)

φ = atan2(y, x)

arccos returns θ in [0, π], which is exactly the polar-angle range. A naive φ = arctan(y/x) does not: it cannot tell (1, 1) from (−1, −1), and it explodes on the y-axis where x = 0. atan2(y, x)* reads both arguments and returns an angle in (−π, π], which this page then wraps into [0, 2π).

r = 0 is a special case: θ and φ are undefined. The form reports θ = 0 and φ = 0 as a convention, not as a geometric fact. Every direction is equally right at the origin, which is another way of saying none is.

Latitude versus colatitude

Geographic latitude δ is measured from the equator, positive north. Colatitude θ is measured from the north pole. They add to 90°:

θ = 90° − δ  ·  δ = 90° − θ

London, latitude about 51.5° N, has colatitude about 38.5°. A physics θ of 90° is the equator, latitude 0. A physics θ of 0 is the north pole, latitude +90°. Mixing the two in a formula is a silent 90° error, which on a sphere is as wrong as it sounds. New York at 40.7° N is θ ≈ 49.3°; a point on the Tropic of Cancer (23.4° N) is θ ≈ 66.6°. South latitudes flip past 90°: 33.9° S (Cape Town) is θ ≈ 123.9°.

The great-circle distance calculator wants latitudes, because that is how maps and GPS speak. This converter wants θ from +z, because that is how the physics formulae are written. Translating is the one-line identity above, not a second conversion algorithm.

Mathematics textbooks that swap θ and φ

A common calculus convention uses ρ for the radius, φ for the angle from +z, and θ for the azimuth — the opposite assignment for the two angles. Both conventions are internally consistent. They are not compatible in the same sentence. A formula x = r sin θ cos φ is physics; the same letters in a multivariable calculus book may mean x = ρ sin φ cos θ.

American high-school “polar” work is 2-D: (r, θ) in the plane, θ from +x. That θ is this page’s φ, not this page’s θ. The collision of names is historical. The practical rule is to read the surrounding sentence: is the angle from the z-axis, or in the xy-plane? The name printed on the angle is not enough.

This site stays with physics (r, θ, φ) on every language version of the page, so a plot of θ from 0 to π is always the polar angle. Switching convention mid-homework is how a sphere integral acquires a rogue factor sin φ instead of sin θ.

The volume element r² sinθ dr dθ dφ

A small box in spherical coordinates is not a cube of sides dr, dθ, dφ. Angles are not lengths. The physical edges are dr, r dθ, and r sin θ dφ, so the volume is

dV = r² sin θ · dr dθ dφ

The r² is the usual spherical growth of area. The sin θ is the shrinking of parallels toward the poles: a step dφ at the equator (θ = π/2) is a long east-west step, and at the pole it is nothing. Integrate sin θ dθ from 0 to π and dφ from 0 to 2π, times r² dr, and the ball of radius R has volume ⁴⁄₃πR³. Lose the sin θ and the volume comes out wrong by a factor of 2, which is a popular examination accident.

Surface measure on the sphere of radius r is r² sin θ dθ dφ. Divide by r² and the solid angle element is dΩ = sin θ dθ dφ, which is the integrand on the solid angle page. The two tools share that factor.

Degenerate cases: the z-axis, the origin, the xy-plane

On the positive z-axis, x = y = 0, z > 0: r = z, θ = 0, φ is arbitrary. On the negative z-axis, θ = π, φ again arbitrary. The origin, as already noted, leaves both angles undefined. Numerically, atan2(0, 0) is platform-defined; this page does not pretend it is a direction.

The xy-plane is θ = 90°. Then z = 0 and (x, y) = (r cos φ, r sin φ), ordinary polar coordinates. Points with r = 0 are the only ones that collapse all three spherical coordinates; a point with θ = 0 still has a well-defined r.

Round-trip tests are cheap: convert (x, y, z) to spherical and back. Off the z-axis the original Cartesian triple should return. On the z-axis, x and y stay 0 and z is recovered; φ may change, which is not a bug.

Physics, geography, and navigation: same point, different names

A physicist’s (r, θ, φ), a geographer’s (latitude, longitude, height), a navigator’s (declination, hour angle) can describe one and the same direction. The frames differ. Geographic longitude is azimuth from Greenwich, not from +x of a lab frame. Astronomical declination is a latitude, not a colatitude. Height above the ellipsoid is not the spherical r unless the origin is the Earth’s centre and the Earth is treated as a sphere.

For a lab-sized problem — a microphone array, a molecule, a robot arm — spherical coordinates in the physics convention are the right tool. For a point on Earth, latitude and longitude plus the trigonometry of the globe are the right tool. Converting between them is a change of origin and of angle zero, not a mystery of arccos.

Radar and antenna patterns often plot gain against θ from the boresight, which is this polar angle if boresight is +z. A “90° off-axis” lobe is the equator of that plot. That sentence is unreadable if θ was the azimuth in the writer’s private convention.

Cylindrical coordinates as a halfway house

Cylindrical (ρ, φ, z) keep the Cartesian z and polarize only the horizontal plane. ρ = √(x² + y²) = r sin θ. The volume element is ρ dρ dφ dz, with no sin θ because the polar angle is gone. Problems with an obvious axis — pipes, solenoids, turning on a lathe — usually want cylindrical. Problems with an obvious origin and no preferred axis — gravity of a ball, radiation from a point — usually want spherical.

Going spherical → cylindrical is θ and r into ρ and z; φ is shared. Going Cartesian → cylindrical uses the same atan2(y, x) as spherical. The two converters are siblings. This page does not add a third tab for cylindrical, because two angles and a radius already determine the point; ρ and z are then derived. A check: r = 2, θ = 60°, φ = 45° gives ρ = √3, z = 1, and Cartesian (√(3/2), √(3/2), 1). Converting that triple back must recover the same r, θ, φ to the displayed digits.

Unit vectors ê_r, ê_θ, ê_φ

Unlike î, ĵ, k̂, the spherical unit vectors change with position. ê_r points outward, ê_θ points toward increasing θ (southward, on a globe with +z north), ê_φ toward increasing φ (eastward). They form a right-handed triad. A displacement is dr ê_r + r dθ ê_θ + r sin θ dφ ê_φ, which is where the volume element’s three edges come from.

Vector calculus in spherical coordinates therefore carries extra connection terms: differentiating ê_r with respect to θ produces ê_θ, and so on. That is the origin of the notorious extra bits in div, grad, and curl. This converter does not compute those operators. It only places the point. Once (r, θ, φ) are known, those unit vectors are known as functions of the angles.

A radial electric field is E(r) ê_r. Writing that in Cartesian components requires exactly the three projection formulae in “spherical to Cartesian,” with E in place of r. Same geometry, different quantity on the arrow.

Glossary

Colatitude (polar angle θ)
The angle from the positive z-axis to the radius vector, from 0 to 180°. Related to geographic latitude δ by θ = 90° − δ. In the physics convention used here, this angle is named θ, not φ.
Azimuth φ
The angle in the xy-plane from the positive x-axis toward positive y, from 0° to 360° on this page. It is not geographic longitude, which is measured from a chosen meridian on Earth.
atan2(y, x)
The two-argument inverse tangent. It returns the signed angle of the vector (x, y) in (−π, π], using the signs of both arguments so all four quadrants are distinct. A single-argument arctan(y/x) cannot do that.

Related calculators