Plotting Lines and Planes in Maple

Copyright 1999, 2001 by James F. Hurley, University of Connecticut Department of Mathematics, 196 Auditorium Rd Unit 3009, Storrs CT 06269-3009. All rights reserved.

Maple can produce high-quality color plots that are easy to visualize and manipulate. Rotation is especially helpful in visualizing surfaces and curves in space.

The simplest curve in either the plane or 3-dimensional real Euclidean space is a line
L , which for plotting purposes it is usually best to describe parametrically . Suppose that L has parametric vector equation

x = x[0] + t v ,


where
x[0] = O P[0] is the vector from the origin to a point P[0] on L , v is a vector in the direction of L and t is the real parameter. It is very simple to generate a parametric plot of the graph of L in R^2 . Maple's two-dimensional graphics package includes a built-in command for that:

plot([x(t),y(t)), t = a..b) .


To execute the command below, position the cursor after the Maple code, and press the Enter key (at the lower right of the keyboard).

> plot( [3 + t, -1 - 2*t, t = -3..3], labels = ["x", "y"] );

[Maple Plot]

For a line in R^3 , the procedure is similar. However, you need to access the plots3d package, which contains the three-dimensional parametric-plotting routine spacecurve . The colon at the end of the call to plots3d in the following routine suppresses printing of the list of all its commands. Execution of the code plots the line whose parametric equations are x = 3 , y = 1 + t , z = -1-5*t as t ranges over the interval [ -3 , 3]. To see the result, put the cursor at the end of second command and press Enter.

> with (plots):
spacecurve( [3, 1 + t, -1 - 5*t], t = -3..3, axes = framed, labels = ["x", "y", "z"] );

Warning, the name changecoords has been redefined

[Maple Plot]

If you click on the plot, bounding lines appear around it and a new plotting menu bar and context bar appear at the top of the screen. If you prefer Maple's "normal" coordinate-axis display, click on the axes menu and select Normal.

A very nice feature of Maple is its interactive 3-dimensional rotation capability, which also is available once you click on the plot. Depress the mouse button and drag the mouse to rotate the graph and view it from any angle. Try it!

The following extended version of the basic routine offers an alternative to Maple's Normal axis display. This adds coordinate axes and labels (magenta in color) to the plot at their actual positions on the plot, rather than at the edges,. The result looks similar to textbook graphs, which this routine thus lets you recreate and explore on your own. In this case, the next figure in the printed version of this worksheet resulted from some rotation of the default plot.

As for the first line of the last routine, a colon at the end of a command suppresses output, so nothing appears when the routine is executed until after creation of all the elements of the plot. The final command instructs Maple to display them all in a single image.

> lineplot := spacecurve( [3 , 1 + t, -1 - 5*t], t = -3..3, axes = framed,
color = red, labels = ["x", "y", "z"] ):
xaxis := spacecurve([t, 0, 0, t = -3..3, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -3..3, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -3..10, color = magenta]) :
labx := textplot3d([3.8, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,3.8, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 12, `z`], color = magenta):
display(lineplot, xaxis, yaxis, zaxis, labx, laby,labz);

[Maple Plot]

Plotting Planes


A vector equation of the plane through the point
P[0] ( x[0] , y[0] , z[0] ) is

(1) n ( x-x[0] ) = 0,


where
n is a normal vector the plane, x is the vector from the origin to an arbitrary point P ( x , y , z ) on the plane and x[0] is the vector from the origin to P[0] . Suppose first that n = a i + b j + c k , where c is not 0. Since x = x i + y j + z k and x[0] = x[0] i + y[0] j + z[0] k , expansion of (1) gives

a*x-a*x[0]+b*y-b*y[0]+c*z-c*z[0] = 0 z = (a*x[0]+b*y[0]+c*z[0]-a*x-b*y)/c .


Maple can plot this equation in 3-space, by treating it as a simple surface. The next routine contains the commands to plot the graph of a surface with equation
z = f ( x , y ). In this case, the plane has normal vector n = 3 i 4 j 6 k and passes through the point ( -1 , 3, -8 ). So a vector equation for it is

( 3, -4, 6 ) ( x+1, y-3, z+8 ) = 0 3*x+3-4*y+12-6*z-48 = 0
z = (33-3*x+4*y)/(-6) .


Execute the next routine to see a plot of the plane. To view the plane from any perspective you choose, click on the plot, depress the mouse button, and then move the mouse to rotate the image in three space. This time, the printed version shows the default plot.

> with (plots):
plot3d( (33 - 3*x + 4*y)/(-6), x = -3..3, y = -3..3, axes = framed, labels =
["x", "y", "z"] );

[Maple Plot]

When the third coordinate of a normal vector is 0, the plane is vertical: its normal vector is entirely in the xy -plane. The best way to plot such a plane is parametrically . Note that if n = a i + b j + 0 k and the plane passes through the point P[0] ( x[0] , y[0] , z[0] ) , then supposing that b is nonzero (at least one of a or b is nonzero), Equation (1) becomes

(2)
a ( x x[0] ) + b ( y y[0] ) = 0 ax + by = a x[0] + b y[0] y = (a*x[0]+b*y[0]-a*x)/b .

Parametric representation of a plane involves two parameters, say s and t , because planes have two dimensions. For a plane with Cartesian equation of the form (2), one such parametric representation is

(3)
x = s , y = (a*x[0]+b*y[0]-a*s)/b , z = t, s R , t R.

The following Maple routine plots the plane through the point ( 3, -1, 2 ) with normal vector n = -2 i + j .

> with (plots):
plot3d( [s, (-6 -1 - 2*s)/1, t], s = -3..3, t = -3..3, axes = framed, labels
= ["x", "y", "z"] );

[Maple Plot]


Finally, what if
b = 0? As noted above, in that case a is not 0. So solve (2) for x instead of y :

x = (a*x[0]+b*y[0]-b*y)/a .


Thus, the parametric equations (3) assume the form

(4)
x = (a*x[0]+b*y[0]-b*s)/a , y = s, z = t, s R , t R.

The following Maple routine plots the vertical plane through the point ( 3, -1, 2 ) with normal vector n = ( -2, 0, 0 ).

> with (plots):
plot3d( [-6/1, s, t], s = -3..3, t = -3..3, axes = framed, labels = ["x", "y", "z"] );

[Maple Plot]

>