Sec15.02AltCoords.mws

Plotting in other coordinate systems

Worksheet by Mike May, S.J.- maymk@slu.edu

> restart;

Since sections 15.5, and 15.6 look at integration in other coordinate systems, it is worthwhile to look at how we can plot with Maple in other coordinate systems. The trick is that maple has a coords option in its plot commands.

>

Functions of one variable

Cartesian Coordinates

We start with the standard cartesian coordinate system. Maple assumes that we will write y as a function of x.

We can also plot parametrically using [x(t), y(t), t=trange].

> plot((x-1)^2-2, x=-1..3);
plot([t, (t-1)^2-2,t=-1..3]);

[Maple Plot]

[Maple Plot]

Polar Coordinates

If we want to use polar coordinates we should note that Maple expects r to be a function of theta.

If we are plotting parametrically Maple expects [r(t), theta(t), t=trange].

> plot(1+2*cos(theta), theta=0..2*Pi, coords=polar);
plot([1+2*cos(t), t, t=0..2*Pi], coords=polar);

[Maple Plot]

[Maple Plot]

Mixed Coordinates

One of the usaeful things we can do is to put plots done with different coordinate systems together with the display command. Note that we want to end the commands of the named plots with a colon rather than a semicolon. (Otherwise we get an ugly list of the postscript commands that make up the plot structures.) To use display we first need to load it with the plots command.

> with(plots);
plota:= plot((x-1)^2-2, x=-1..3, color=red):
plotb:= plot(1+2*cos(theta), theta=0..2*Pi, coords=polar, color=blue):
display({plota, plotb});

Warning, the name changecoords has been redefined

[animate, animate3d, animatecurve, changecoords, co...
[animate, animate3d, animatecurve, changecoords, co...
[animate, animate3d, animatecurve, changecoords, co...
[animate, animate3d, animatecurve, changecoords, co...
[animate, animate3d, animatecurve, changecoords, co...

[Maple Plot]

Exercises:

1) Plot the graph of a 5 petal rose of radius 2 with a petal cut by the positive x-axis. (You should remember the formula for this from pre-calculus.

>

2) Plot the cartiod defined by r=1-sin(theta) on the same axes as the graph of y=2+sin(Pi*x) to create a picture of a heart with a hat.

>

Functions of two variables

Cartesian Coordinates

We start surfaces that are the plots of functions in two variables with cartesian coordiantes. In a parallel fashion, Maple assumes that we will write z as a function of x and y.

If we are going to parameterize the surface, it is assumed to be in the form ([x(u,v), y(u, v), z(u, v)], u=urange, v=vrange).

> plot3d(sin(x^2+y^2), x=-3..3, y=-3..3, style=patch, axes=boxed, grid=[60,60]);
plot3d([u, v, sin(u^2+v^2)], u=-3..3, v=-3..3, style=patch, axes=boxed, grid=[60,60]);

[Maple Plot]

[Maple Plot]

Cylindrical Coordinates

The next coordinate system we want to look at is the cylindrical coordinates. Maple assumes that we will express r as a function of theta and z. (in class we typically express z as a function of r and theta.) This means that we have to use the parametric form if we want to do the sombrero surface above. (The graph above has many r values corresponding to a single value of theta and z, so r is not a function of theta and z.)

Interestingly, the parametric form arranges the variables in the more familiar (r, theta, z) pattern so the form is ([r(u,v), theta(u,v), z(u,v)], u=urange, v=vrange).

> plot3d([r, theta, sin(r^2)], r=0..4, theta=0..2*Pi, coords=cylindrical, style=patch, axes=boxed, grid=[100,100]);

[Maple Plot]

The cylindrical form is useful for plotting surfaces obtained by rotating curves around the z axis. Cylinders are the easiest example of this. They are obtained by rotating lines of the form y=c about the x-axis.

> plot3d({1, 3+sin(z)}, theta=0..2*Pi, z=-4..4, style=patch, axes=boxed, coords=cylindrical, grid=[60,60]);

[Maple Plot]

>

Spherical coordiantes

Maple assumes that spherical coordinates will express rho as a function of theta and phi. The easiest surface to graph is, as the name of the system suggests, a sphere centered at the origin.

> plot3d(2, theta=0..2*Pi, phi=0..Pi, coords=spherical, style=patch, axes=boxed, grid=[60,60]);

[Maple Plot]

If we are doing a more complicated surface we may want to use the parametric form. In that Case Maple asumes that the form will be ([rho(u,v), theta(u,v), phi(u,v)], u=urange, v=vrange).

> plot3d(4+5*cos(2*phi)+3*sin(3*theta), theta=0..2*Pi, phi=0..Pi, coords=spherical, style=patch, axes=boxed, grid=[60,60]);
plot3d([4+5*cos(2*phi)+3*sin(3*theta), theta, phi], theta=0..2*Pi, phi=0..Pi, coords=spherical, style=patchnogrid, axes=boxed, grid=[40,40], lightmodel=light1);

[Maple Plot]

[Maple Plot]

Mixed coordinates

Once again, a nice trick is to use display3d to put together surfaces that are easy to describe in different coordinate systems. The code below putes togeter the plane z=x+y (cartesian coordinates), the cylinder r=2 (cylindrical coordinates), and the sphere rho = 3 (spherical coordinates).

> plotplane := plot3d(x+y, x=-4..4, y=-4..4, style=patch, color=yellow, axes=boxed, grid=[60,60]):
plotcyl := plot3d(2, theta=0..2*Pi, z=-8..8, style=patch, color=pink, axes=boxed, coords=cylindrical, grid=[60,60]):
plotsph := plot3d(3, theta=0..2*Pi, phi=0..Pi, style=patch, color=green, axes=boxed, coords=spherical, grid=[60,60]):
display3d({plotplane, plotcyl, plotsph});

[Maple Plot]

Exercises:

3) Plot a sphere of radius 3 centered at the origin in each of the three coordinate systems we have discussed. Which is easiest?

>

4) Plot a cone with point at the origin, height 4 and radius 3 using your favorite coordinate system.

>

>