How to Illustrate a 3-D Function Restricted to a 2-D curve
by Waterloo Maple, 2001
As an example, let's illustrate the behavior of the function over the ellipse .
> restart;
> with(plots):
Warning, the name changecoords has been redefined
Define the function z
> z := 2+3/(1+x^2+y^2);
Here's the graph of z by itself.
> surface := plot3d(z, x=-2.5..2.5, y=-2.5..2.5, color=magenta, style=wireframe, orientation=[135,70], scaling=constrained, axes=boxed, grid=[20,20]):
> surface;
Parametrize the ellipse over t .
> xt := 2 * cos(t): yt := sin(t):
Here's the ellipse drawn in the plane. Just a spacecurve with z -component of 0.
> planeCurve := spacecurve([xt, yt, 0], t=0..2*Pi, color=blue, thickness=2, axes=boxed, orientation=[135,70], scaling=constrained): planeCurve;
Project the ellipse to the function's graph by substituting x(t) and y(t) in for x and y in z .
> zt := subs( {x=xt, y=yt}, z ):
Draw the function restricted to the ellipse as a space curve with components x(t) , y(t) and z(t) .
> surfaceCurve := spacecurve([xt, yt, zt], t=0..2*Pi, color=black, thickness=4, orientation=[135,70], scaling=constrained, axes=boxed): surfaceCurve;
Combine the three pieces into one display.
> display({surface, planeCurve, surfaceCurve}, axes=boxed, scaling=constrained, orientation=[135,70]);
> zeroPlane := plot3d(0, x=-2.5..2.5, y=-2.5..2.5, color=grey, grid=[10,10], axes=boxed, scaling=constrained, orientation=[135,70]):
> zeroPlane;
Let's add one more visual aid to this diagram: vertical lines mapping points on the ellipse to points on the surface
> numLines := 30;
> for i from 1 to numLines do t := (i/numLines)*2*Pi; lines[i]:=plottools[line]([xt,yt,0], [xt,yt,zt], color=green, linestyle=1, thickness=2); end do:
Here are the lines by themselves with the curve set on top
> display( {seq(lines[i], i=1..numLines), planeCurve, surfaceCurve, zeroPlane}, axes=boxed, scaling=constrained, orientation=[135,70]);
The whole picture.
> display( { seq(lines[i], i=1..numLines), planeCurve, surfaceCurve, surface, zeroPlane}, axes=boxed, scaling=constrained, orientation=[135,70], axes=framed, labels=["x", "y", "z"],labelfont=[TIMES, BOLD,14]);
> t := 't';
> z;
> z2 := z + t*sin(3*x*y);
> #plots[animate3d](z2, x=-2..2, y=-2..2, t=0..(.5), frames=30, orientation=[-60,60]);
>