ParametricPlot3D with spherical and cylindrical coordinates

Mathematica has special built-in functions for graphing cylindrical and polar coordinates (CylinderPlot3D and SphericalPlot3D).  Unfortunately, these aren't really as versatile as we might wish.  For example, they wouldn't be capable of plotting something as simple as φ=π/6.  Both of these commands are based on a much more flexible command, ParametricPlot3D.

ParametricPlot3D requires a function from either R^3 or ^2^3 as an input.  It will then graph the range of the function.  Thus:

curve[t_] := {t, Sin[t], Cos[2t]}

ParametricPlot3D[curve[t], {t, 0, 3π}]

[Graphics:../HTMLFiles/index_81.gif]

⁃Graphics3D⁃

If you like, you can use ParametricPlot3D to draw a surface:

surface[u_, v_] := {u Sin[v], u Cos[v], u^2}

ParametricPlot3D[surface[u, v], {u, -1, 1}, {v, 0, 2π}]

[Graphics:../HTMLFiles/index_85.gif]

⁃Graphics3D⁃

You can even use ParametricPlot3D to graph a function of 2 variables:

f[x_, y_] := x^2 + y^2

ParametricPlot3D[{x, y, f[x, y]}, {x, -1, 1}, {y, -1, 1}]

[Graphics:../HTMLFiles/index_89.gif]

⁃Graphics3D⁃

(If you had used the Plot3D function instead, it would have looked a little nicer...)

Problem

These two graphs look suspiciously alike.  Show that they are really the same surface.  Why do they look so different?

In order to use ParametricPlot3D to graph things in spherical and cylindrical coordinates, you must first develop a "change of variable" function. For example, a change of variable function for polar coordinates might look something like:

polarToRect[{r_, θ_}] := {r Cos[θ], r Sin[θ]}

rectToPolar[{x_, y_}] := {(x^2 + y^2)^(1/2), ArcTan[y/x]}

polarToRect[{2, π/6}]

{3^(1/2), 1}

rectToPolar[{3^(1/2), 1}]

{2, π/6}

rectToPolar[polarToRect[{2, π/6}]]

{2, π/6}

Warning:

rectToPolar[{-3^(1/2), 1}]

{2, -π/6}

Problem

What is wrong with this and why?

Fortunately, we are mainly interested in polarToRect (actually the equivalents for cylindrical and spherical coordinates).

Problem

Create 2 new functions: cylinderToRect (accepts points in the form {r,θ,z}) and sphereToRect (accepts points in the form {ρ,θ,φ}) to make the appropriate conversions.  Notice that both of these functions are from ^3^3.

You can use these new functions in conjunction with ParametricPlot3D to graph most equations in cylindrical and spherical coordinates. (You can even use it to graph cylindrical or spherical "parametric equations," something you don't see in many textbooks...)

For example, to graph something like ρ=Sin[θ]Cos[φ], you would do something like:

In[158]:=

ρ = Sin[θ] Cos[ϕ]

ParametricPlot3D[sphereToRect[{ρ, θ, ϕ}], {θ, 0, 2π}, {ϕ, 0, 2π}]

(Notice that you can only have 2 independent variables inside ParametricPlot3D, θ and φ in this case.)

Of course, the built-in SphericalPlot3D function could have done this (with less effort). However, you can also use your new functions to plot θ=π/4:

ParametricPlot3D[sphereToRect[{ρ, π/4, ϕ}], {ρ, 0, 5}, {ϕ, 0, π}]

Problem

Use the functions you developed above to graph the following (carefully choose what regions to graph over):

1. r=z cos(2θ)

2. φ=ρ sin(θ/2)

3. r=sin(u)cos(v), θ=sin(u v), z=cos(u+v)


Created by Mathematica  (February 28, 2007) Valid XHTML 1.1!