ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Rectangular to Spherical Coordinates & Vice Versa

Updated on January 18, 2015
calculus-geometry profile image

TR Smith is a product designer and former teacher who uses math in her work every day.

The surface x^2 + zy^2 = 20
The surface x^2 + zy^2 = 20

Knowing how to convert rectangular coordinates to spherical coordinates, and how to convert spherical coordinates to rectangular coordinates, can help you express equations of surfaces in more compact forms. Spherical coordinates are the 3-D analogue of polar coordinates in 2-D space.

Depending on the 3-d surface, the rectangular (Cartesian) expression may be simpler, or the spherical representation may be more efficient. For example, a plane given by the equation z = ax + by + c has a simple representation in Cartesian xyz-coordinates, but a rather complicated expression in spherical rθφ-coordinates. On the other hand, the equation of a sphere of radius 2 centered at the origin is simply r = 2 in spherical coordinates, while in rectangular coordinates the equation is 4 = z^2 + y^2 + x^2. Here is an explanation of spherical coordinates and several examples to help you convert between coordinate systems.

What Are Spherical Coordinates?

Rectangular (x, y, z) coordinates encode the positions of points by telling you how far along it is along the x-, y-, and z-axes. For example, rectangular coordinate point (1, 9, 3) is 1 unit to the right, 9 units forward, and 3 units up.

Spherical coordinates tell you the position of a point according to its distance from the origin r, its azimuth angle θ, and its polar angle φ.

The azimuth angle ranges from 0 to 2π radians and is the angle of the point with respect to the positive x-axis on the xy-plane. The polar angle ranges from 0 to π and is the angle of the point with respect to the z-axis. For reference, a point on the positive z-axis has a polar angle of 0, a point on the xy-plane has an angle of π/2, and a a point on the negative z-axis has a polar angle of π.

Another way to think about azimuth and polar angles is that the azimuth angle is equivalent to longitude on a globe, while the polar angle is equivalent to latitude on a globe.

Illustration of Spherical Coordinates and Rectangular Coordinates in the Same 3-D Space

Conversion Formulas Spherical to Cartesian, Cartesian to Spherical

If a point is given in rectangular (Cartesian) coordinates as (x, y, z), then its spherical representation (r, θ, φ) is given by the equations

r = sqrt(x^2 + y^2 + z^2)
θ = arccos(z/r)
φ = arctan(y/x)

The azimuth angle φ may need to augmented by π or 2π to put it in the correct quadrant in the xy-plane.

If a point is given by the spherical coordinates (r, θ, φ), then its Cartesian coordinate representation (x, y, z) is given by the equations

x = r*sin(φ)*cos(θ)
y = r*sin(φ)*sin(θ)
z = r*cos(φ)

Example 1

Let's convert the rectangular coordinates (4, 13, -16) to spherical coordinates. First, we have x = 4, y = 13, and z = -16. The radius coordinate, r, is

r = sqrt(4^2 + 13^2 + (-16)^2)
= sqrt(16 + 169 + 256)
= sqrt(441)
= 21

The xy-plane angle or azimuth angle, θ, is

tan(θ) = 13/4
θ = arctan(13/4)
θ ≈ 1.272 radians

Finally, the z-axis angle or polar angle, φ, is

sin(φ) = sgn(z)*sqrt(x^2 + y^2)/sqrt(x^2 + y^2 + z^2)
sin(φ) = (-1)*sqrt(185)/sqrt(441)
φ = arcsin[-sqrt(185)/21]
φ ≈ 2.437 radians

Therefore, the rectangular coordinate point (4, 13, -16) is equivalent to (21, 1.272, 1.016) in spherical coordinates.


Example 2

Going the other direction, let's convert the spherical coordinate point (1, π/4, π/6) to rectangular coordinates. First we have r = 1, θ (azimuth angle) = π/4 or 45°, and φ (polar angle) = π/6 or 30°. This is a point on the unit sphere centered at the origin.

The value of the x-coordinate is

x = r*sin(φ)*cos(θ)
x = 1*sin(π/6)*cos(π/4)
x = [1/2]*[sqrt(2)/2]
x = sqrt(2)/4 ≈ 0.3536

The value of the y-coordinate is

y = r*sin(φ)*sin(θ)
y = 1*sin(π/6)*sin(π/4)
y = [1/2]*[sqrt(2)/2]
y = sqrt(2)/4 ≈ 0.3536

The value of the z-coordinate is

z = r*cos(φ)
z = 1*cos(π/6)
z = sqrt(3)/2 ≈ 0.8660

Therefore the equivalent rectangular coordinates representation is (sqrt(2)/4, sqrt(2)/4, sqrt(3/2)).


Surfaces in Polar Coordinates

Equations of surfaces expressed in Cartesian coordinates can be expressed in spherical coordinates, and sometimes the spherical versions are much cleaner and more efficient. For example, the equation of the unit sphere in rectangular coordinates is

x^2 + y^2 + z^2 = 1

But in spherical coordinates this equation is simply r = 1. A cone defined by the equation

z = 2*sqrt(x^2 + y^2)

is equivalent to

r*cos(φ) = 2*sqrt[(r*sin(φ)*cos(θ))^2 + (r*sin(φ)*sin(θ))^2]

which simplifies to

φ = arctan(1/2)

A cylinder whose central axis coincides with the z-axis has the Cartesian equation x^2 + y^2 = K, where K is some constant. The equivalent equation in spherical coordinates is

(r*sin(φ))^2 = K

These are some of the simplest examples of well-known surfaces that are easy to convert to spherical coordinates. Here are some examples of more challenging surfaces.


Example 3

Rewrite the surface z = 1/(1 + x^2 + y^2) as a spherical coordinate equation. This is a smooth and continuous surface that looks like 2-variable graph y = 1/(x^2 + 1) rotated around the y-axis to produce a surface of revolution. Another way to visualize it is a flat sheet with a bump at the origin. To convert it to a spherical coordinate form, we use the transformations

x = r*sin(φ)*cos(θ)
y = r*sin(φ)*sin(θ)
z = r*cos(φ)

and plug them into the rectangular coordinate equation of the surface. This gives us

r*cos(φ) = 1/[1 + (r*sin(φ)*cos(θ))^2 + (r*sin(φ)*sin(θ))^2]

r*cos(φ) = 1/[1 + (r*sin(φ))^2]


This is not an equation that allows easy isolation of the variables, so the cleanest form to leave it in is this implicit form. Notice that the sperical coordinate representation does not include the variable θ, the angle on the xy-plane. This is because the surface is symmetric and remains unchanged when you rotate it parallel to the xy-plane around the z-axis.


The surface z = 1/(1 + x^2 + y^2)
The surface z = 1/(1 + x^2 + y^2)

Example 4

Consider the spherical coordinate surface defined by r = cos(φ)+sin(θ) and restricted to the first octant, i.e., the part of xyz-space between the positive x-, y-, and z-axes. To convert this surface into a rectangular/Cartesian coordinate equation, the key step is to use the substitutions

r = sqrt(x^2 + y^2 + z^2)
θ = arctan(y/x)
φ = arcsin[sqrt(x^2 + y^2)/sqrt(x^2 + y^2 + z^2)]

We can ignore issues with the signs of the variables because we are restricting to the first octant. We also need the trig identities

sin(arctan(C)) = C/sqrt(C^2 + 1)
cos(arcsin(C)) = sqrt(1 - C^2)

With these relations, we can now transform our original spherical coordinate equation.

sqrt(x^2 + y^2 + z^2) = sqrt[1 - (x^2 + y^2)/(x^2 + y^2 + z^2)] + (y/x)/sqrt(1 + (y/x)^2)

sqrt(x^2 + y^2 + z^2) = z/sqrt(x^2 + y^2 + z^2)+ y/sqrt(x^2 + y^2)

x^2 + y^2 + z^2 = z + y*sqrt(x^2 + y^2 + z^2)/sqrt(x^2 + y^2)

[(x^2 + y^2 + z^2 - z)/y]^2 = (x^2 + y^2 + z^2)/(x^2 + y^2)

(x^2 + y^2)(x^2 + y^2 + z^2 - z)^2 = (x^2 + y^2 + z^2)y^2

(x^2 + y^2)(x^2 + y^2 + z^2 - z) = y^2

x^4 + 2(xy)^2 + (xz)^2 - (x^2)z + y^4 + (yz)^2 - (y^2)z - y^2 = 0

This is a rather complicated implicitly defined surface. Below are several views of this surface. Notice that the surface is bounded. This is because the equation r = cos(φ)+sin(θ) can have a maximum radius of 2.

The surface x^4 + 2(xy)^2 + (xz)^2 - (x^2)z + y^4 + (yz)^2 - (y^2)z - y^2 = 0
The surface x^4 + 2(xy)^2 + (xz)^2 - (x^2)z + y^4 + (yz)^2 - (y^2)z - y^2 = 0

Comments

    0 of 8192 characters used
    Post Comment

    • paxwill profile image

      paxwill 2 years ago from France

      Nice surface plots. What program did you use to generate the 3-d graphs?

    Click to Rate This Article