Vectors, Lines, and Planes in Maple 

 

This worksheet explores basic vector commands in Maple as well as dealing with lines and planes. 

Maple worksheet: vectors.mw 

 

First, we must load the VectorCalculus package to compute with vectors and the plots package for some of our plots. 

 

> restart;
with(VectorCalculus):
with(plots):
 

 

The VectorCalculus package allows us to easily perform various vector operations. A vector is denoted "<1, 2, 3>" and Maple prints out: "VectorCalculus:-`+`(VectorCalculus:-`+`((exp(1))[x], VectorCalculus:-`*`(2, e[y])), VectorCalculus:-`*`(3, e[z]))" where  "(exp(1))[x]" is the i = (1,0,0) unit vector and so forth. 

 

To compute a dot product use "." and to compute a cross product use "&x". 

 

> <1,2,3> . <4,5,6>;
 

32 (1)
 

> <1,2,3> &x <4,5,6>;
 

Vector[column](%id = 18446744078108601390) (2)
 

 

Example: Consider the following vectors: v and w (defined below).
     
 

> u := <-3, 3,-6>;
v := <-1, 4, 1>;
w := < 1,-1, 2>;
 

 

 

Vector[column](%id = 18446744078108601630)
Vector[column](%id = 18446744078108601750)
Vector[column](%id = 18446744078108601870) (3)
 

 

Let's find the angle between u and v. 

 

> arccos(u.v/(Norm(u)*Norm(v)));
 

arccos(`+`(`*`(`/`(1, 12), `*`(`^`(6, `/`(1, 2)), `*`(`^`(2, `/`(1, 2))))))) (4)
 

> # Decimal approximation in radians.
evalf(arccos(u.v/(Norm(u)*Norm(v))));
 

1.277953555 (5)
 

> # Decimal approximation in degrees.
evalf(arccos(u.v/(Norm(u)*Norm(v)))*180/Pi);
 

73.22134511 (6)
 

 

Now let's show that u and v are not parallel, but u and w are. [Recall that two vectors are parallel if and only if there cross product is the zero vector.] 

 

> u &x v;
u &x w;
 

 

Vector[column](%id = 18446744078120857462)
Vector[column](%id = 18446744078120849646) (7)
 

 

Three vectors are coplanar if and only if there triple scalar product is zero, so these vectors are coplanar. 

 

> u.(v &x w);
 

0 (8)
 

 

Example: Let's compute 3v - 2w,  v·w, and v×w where v = `<,>`(2, 4, -2) and w = `<,>`(3, 0, -2). 

 

> v := < 2, 4, -2>;
w := < 3, 0, -2>;

3*v-2*w;
v.w;
v &x w;
 

 

 

 

 

Vector[column](%id = 18446744078120851086)
Vector[column](%id = 18446744078120851206)
Vector[column](%id = 18446744078120852526)
10
Vector[column](%id = 18446744078120846390) (9)
 

 

Let's find a unit vector pointing in the same direction as w (in other words, let's normalize w). 

 

> Normalize(w);
 

Vector[column](%id = 18446744078120846750) (10)
 

 

Alternate ways of normalizing  w: 

 

[Be careful. "Norm" computes the Euclidean (usual) length of a vector. "norm" does not. 

 

> w/Norm(w);
w/sqrt(w.w);
 

 

Vector[column](%id = 18446744078120847830)
Vector[column](%id = 18446744078120848190) (11)
 

 

Now let's compute the projection of w onto v: proj[v](w) and call this vector p. Then we will let q be the vector perpendicular to p so that p + q = w. Finally, we will plot all four of these vectors together. 

 

> p := (w.v)/(v.v)*v;
q := w-p;
 

 

Vector[column](%id = 18446744078120848910)
Vector[column](%id = 18446744078120841574) (12)
 

 

The "arrow" command allows us to plot vector arrows. We give this command a point and a vector and it plots the vector based at that point. Sometimes we need to plot several things together. If we can't get a single command to produce all the plots at once, we can instead plot each part assigning it a name and then use the "display" command to show them all together. 

 

The vector w is black, v is red, p = proj[v](w) is green, and q is blue. Notice that p and q are perpendicular, VectorCalculus:-`+`(p, q) = w, and p and v are parallel. 

 

> vA := arrow(v, shape=arrow, color=red, thickness=3):
wA := arrow(w, shape=arrow, color=black, thickness=3):
pA := arrow(p, shape=arrow, color=green, thickness=5):
qA := arrow(p,q, shape=arrow, color=blue, thickness=5):
display({vA,wA,pA,qA}, scaling=constrained, axes=boxed,orientation=[-170,-20,-120],viewpoint=circleleft);
 

Plot_2d
 

 

Example: A parallelogram has vertices:  (1, 1), (4, 2), (3, 6), and (0,5). Let's plot two vectors which span this parallelogram together with the parallelogram and then find its area. 

                       

Let's make (1,1) our base point and draw vectors to (4,2) and (0,5). After plotting these things, we'll see that (3,6) is the vertex opposite (1,1). 

 

> a := <4,2> - <1,1>;
b := <0,5> - <1,1>;
 

 

Vector[column](%id = 18446744078120839518)
Vector[column](%id = 18446744078120840598) (13)
 

 

Notice the remaining point will give you the diagonal a+b: 

 

> <3,6> - <1,1> = a+b;
 

Vector[column](%id = 18446744078120833502) = Vector[column](%id = 18446744078120834102) (14)
 

> aA := arrow(a, shape=arrow, color=green, thickness=3):
bA := arrow(b, shape=arrow, color=red, thickness=3):
abPar := polygonplot([convert(<0,0>,list), convert(a,list),convert(a+b,list),convert(b,list)],color=grey):
display({aA,bA,abPar}, scaling=constrained, axes=none);

Area := Norm(<3,1,0> &x <-1,4,0>);
 

 

Plot_2d
13 (15)
 

 

Example: We will plot u = `<,>`(1, 2, 3), v = `<,>`(VectorCalculus:-`+`(1, -1), 1), their cross product, VectorCalculus:-`+`(u, v), and the parallelogram which they span. 

 

Notice that if we parameterize the plane (through the origin) spanned by u and v and restrict the parameters properly, we should end up with the parallelogram. 

 

In particular, r(s, t) = VectorCalculus:-`+`(VectorCalculus:-`+`(`<,>`(0, 0, 0), VectorCalculus:-`*`(s, u)), VectorCalculus:-`*`(t, v))  parameterizes the plane (through the origin) spanned by u and v. If we restrict our parameters: `<=`(0, s), `<=`(t, 1), then we will only fill out the parallelogram spanned by u and v. 

 

> u := <1,2,3>;
v := <1,-1,1>;
 

 

Vector[column](%id = 18446744078120836622)
Vector[column](%id = 18446744078120836742) (16)
 

> uPlot := arrow(<0,0,0>,u,shape=arrow,color=red,thickness=3):
vPlot := arrow(<0,0,0>,v,shape=arrow,color=blue,thickness=3):
uCROSSvPlot := arrow(<0,0,0>,u &x v,shape=arrow,color=black,thickness=3):
uATvPlot := arrow(v,u,shape=arrow,color=red,thickness=3):
vATuPlot := arrow(u,v,shape=arrow,color=blue,thickness=3):
uPLUSvPlot := arrow(<0,0,0>,u+v,shape=arrow,color=green,thickness=3):
parallelogramPlot := plot3d(<0,0,0>+s*u+t*v,s=0..1,t=0..1,color=yellow):

display({uPlot,vPlot,uCROSSvPlot,uATvPlot,vATuPlot,uPLUSvPlot,parallelogramPlot},scaling=constrained,orientation=[173,-78],viewpoint=circleleft);
 

Plot_2d
 

 

Example: Consider the line parameterized by r(t) = VectorCalculus:-`+`(P, VectorCalculus:-`*`(a, t)) (defined below). We wish to find the vector b = PQ and then compute the distance from the point Q to the line using the formula: Dist = VectorCalculus:-`*`(abs(Typesetting:-delayCrossProduct(b, a)), `/`(1, `*`(abs(a)))).   

 

> Q := <4,2,6>;

P := <2,1,-1>;
a := <1,-1,3>;
r := t -> P+a*t:
'r(t)' = r(t);
 

 

 

 

Vector[column](%id = 18446744078120828790)
Vector[column](%id = 18446744078120820734)
Vector[column](%id = 18446744078120820854)
r(t) = Vector[column](%id = 18446744078120821574) (17)
 

> b := Q-P;
 

Vector[column](%id = 18446744078120822414) (18)
 

> Dist := Norm(b &x a)/Norm(a);
 

`+`(`*`(`/`(1, 11), `*`(`^`(110, `/`(1, 2)), `*`(`^`(11, `/`(1, 2)))))) (19)
 

> simplify(Dist);
 

`*`(`^`(10, `/`(1, 2))) (20)
 

 

Now let's compute the projection of b onto a: proj[a](b) and call this vector p. Also, let q be the vector perpendicular to p so that p + q = b. Finally, we will plot all four vectors (based at point P) together and find the length of q. 

 

> p := ((a.b)/(a.a))*a;
q := b-p;

aA := arrow(P,a, shape=arrow, color=red, thickness=7):
bA := arrow(P,b, shape=arrow, color=gray, thickness=3):
pA := arrow(P,p, shape=arrow, color=green, thickness=3):
qA := arrow(P,q, shape=arrow, color=blue, thickness=3):
linePlot := spacecurve(r(t),t=-1..3,color=black):
pointQ := pointplot3d(Q,symbolsize=10,symbol=sphere,color=red):

display({aA,bA,pA,qA,linePlot,pointQ}, scaling=constrained, axes=boxed, orientation=[10,90],viewpoint=circleleft);

Norm(q);
 

 

 

 

Vector[column](%id = 18446744078120817358)
Vector[column](%id = 18446744078120818198)
Plot_2d
`*`(`^`(10, `/`(1, 2))) (21)
 

 

How are the distance Dist and the length abs(q) related? They are exactly the same! The vector q is perpendicular to the direction of the line and points from the line to point Q. So it's length is the distance between the point and the line. This is just an alternatively way of finding the distance. 

 

 

Example: A certain parallelogram has vertices: (2,2,5), (3,2,4.5), (4,4,2.5), and (3,4,3). 

      

    I have plotted this parallelogram along with its projections onto the 3 coordinate planes below. Note that, for example, its projection onto the xy-plane (i.e. z = 0) is the parallelogram with vertices: (2,2,0), (3,2,0), (4,4,0), and (3,4,0). 

 

> restart;
with(VectorCalculus):
with(plots):
with(plottools):

x0 := [2,2,5]:
a := [1,0,-1/2]:
b := [1,2,-2]:

P := [x0,x0+a,x0+a+b,x0+b]:
Px := [[0,P[1][2],P[1][3]],[0,P[2][2],P[2][3]],[0,P[3][2],P[3][3]],[0,P[4][2],P[4][3]]]:
Py := [[P[1][1],0,P[1][3]],[P[2][1],0,P[2][3]],[P[3][1],0,P[3][3]],[P[4][1],0,P[4][3]]]:
Pz := [[P[1][1],P[1][2],0],[P[2][1],P[2][2],0],[P[3][1],P[3][2],0],[P[4][1],P[4][2],0]]:

Pplot := polygon(P,  color=green,linestyle=dash,thickness=2, transparency=0.5):
Pxplot := polygon(Px, color=blue,linestyle=dash,thickness=2),seq(line(P[i],Px[i],color=black,linestyle=dash,thickness=2),i=1..4):
Pyplot := polygon(Py, color=red,linestyle=dash,thickness=2),seq(line(P[i],Py[i],color=black,linestyle=dash,thickness=2),i=1..4):
Pzplot := polygon(Pz, color=violet,linestyle=dash,thickness=2),seq(line(P[i],Pz[i],color=black,linestyle=dash,thickness=2),i=1..4):

display(Pplot,Pxplot,Pyplot,Pzplot,orientation=[24,80],scaling=constrained,axes=normal,projection=0.85,tickmarks=[0,0,0],viewpoint=circleleft);
 

Plot_2d
 

 

We will compute the area of the parallelogram and assign it to the variable A. Then we will compute the areas of its 3 projections calling these areas and T. 

 

Let P, Q, X, and Y be the vertices of the parallelogram. (I've replaced decimals with fractions so Maple does exact computations.) 

 

> P := <2,2,5  >;
Q := <3,2,9/2>;
X := <4,4,5/2>;
Y := <3,4,3  >;
 

 

 

 

Vector[column](%id = 18446744078108599590)
Vector[column](%id = 18446744078108599830)
Vector[column](%id = 18446744078108599950)
Vector[column](%id = 18446744078108600070) (22)
 

 

Here are the vectors pointing from P to the other vertices. 

 

> a := Q-P;
b := X-P;
c := Y-P;
 

 

 

Vector[column](%id = 18446744078108601030)
Vector[column](%id = 18446744078108601870)
Vector[column](%id = 18446744078119121254) (23)
 

 

Notice that a+c = b. This means X is the vertex opposite P. Thus the vectors a & c span the parallelogram.  

 

> a+c = b;
 

Vector[column](%id = 18446744078119121854) = Vector[column](%id = 18446744078108601870) (24)
 

 

So the parallelogram is spanned by `<,>`(1, 0, VectorCalculus:-`-`(`/`(1, 2))) and `<,>`(1, 2, -2). 

 

To get vectors spanning the projections of this parallelogram. We should replace in 

turn the i, j, and then k components in these vectors with zeros. 

 

Finally, recall that the area of a parallelogram is given by the length of the cross 

product of two vectors spanning that parallelogram. 

 

> A := Norm(<1,0,-1/2> &x <1,2,-2>);

R := Norm(<0,0,-1/2> &x <0,2,-2>);
S := Norm(<1,0,-1/2> &x <1,0,-2>);
T := Norm(<1,0,   0> &x <1,2, 0>);
 

 

 

 

`+`(`*`(`/`(1, 2), `*`(`^`(29, `/`(1, 2)))))
1
`/`(3, 2)
2 (25)
 

 

Notice that the sum of the squares of the areas of the projections is the square of the area of the parallelogram. There is a 3D version of the Pythagorean theorem which says this is always the case! 

 

> A^2 = R^2 + S^2 + T^2;
 

`/`(29, 4) = `/`(29, 4) (26)
 

 

Example: A parallelepiped is spanned by the vectors: a, b, and c (defined below). Let's find the volume of this parallelepiped then plot this shape along with vectors a, b, & c. 

 

> restart;
with(VectorCalculus):
with(plots):

a := <2,1,1>;
b := <0,2,1>;
c := <1,2,0>;

Volume := abs(a . (b &x c));
 

 

 

 

Vector[column](%id = 18446744078108598390)
Vector[column](%id = 18446744078108598630)
Vector[column](%id = 18446744078108598750)
5 (27)
 

> aA := arrow(a, shape=arrow, color=red, thickness=3):
bA := arrow(b, shape=arrow, color=green, thickness=3):
cA := arrow(c, shape=arrow, color=blue, thickness=3):
s1 := polygonplot3d([convert(<0,0,0>,list),convert(a,list),convert(a+b,list),convert(b,list)],color=grey):
s2 := polygonplot3d([convert(<0,0,0>,list),convert(a,list),convert(a+c,list),convert(c,list)],color=grey):
s3 := polygonplot3d([convert(<0,0,0>,list),convert(b,list),convert(b+c,list),convert(c,list)],color=grey):
s4 := polygonplot3d([convert(a,list),convert(a+b,list),convert(a+b+c,list),convert(a+c,list)],color=grey):
s5 := polygonplot3d([convert(b,list),convert(b+c,list),convert(a+b+c,list),convert(a+b,list)],color=grey):
s6 := polygonplot3d([convert(c,list),convert(a+c,list),convert(a+b+c,list),convert(b+c,list)],color=grey):
display({aA,bA,cA,s1,s2,s3,s4,s5,s6},scaling=constrained,axes=none,orientation=[-75,50,60],viewpoint=circleleft);
 

Plot_2d
 

 

Alternatively, we could use the "parallelepiped" command to plot our box. 

 

Here's a little breakdown of my cryptic (fourth) command: "plottools[parallelepiped]" calls the function which plots a parallelepiped. This function is found in the "plottools" package. I didn't use "with(plottools):" to load the whole package because it would then overwrite the "arrow" command and break my other code. "op" strips "[" and "]" off of a list. So for example, "op([1,2,3]);" returns "1,2,3" then "map(convert,[a,b,c],list)" applies the "convert" command to a, b, and c with a second argument of "list". So it returns "[convert(a,list), convert(b,list), convert(c,list)]" 

 

> aA := arrow(a, shape=arrow, color=red, thickness=3):
bA := arrow(b, shape=arrow, color=green, thickness=3):
cA := arrow(c, shape=arrow, color=blue, thickness=3):
pPiped := plottools[parallelepiped](op(map(convert,[a,b,c],list)),color=gray):
display({aA,bA,cA,pPiped},scaling=constrained,axes=none,orientation=[-75,50,60],viewpoint=circleleft);
 

Plot_2d
 

 

Example: A regular octahedron is a convex regular polygon with 8 sides. Each side is an equilateral triangle, 4 such triangles meet at each vertex. This is a highly symmetric object -- in fact, it has 24 rotational symmetries [For those who've taken MAT 3110: its group of rotations is isomorphic to the symmetric group S[4].]  I have graphed an octahedron below whose vertices are located at `&+-`(1), 0, 0, 0, `&+-`(1), 0, 0, 0, `&+-`(1). 

 

> s1 := polygonplot3d([[ 1, 0, 0], [ 0, 1, 0], [ 0, 0, 1], [ 1, 0, 0]], color=grey):
s2 := polygonplot3d([[ 1, 0, 0], [ 0,-1, 0], [ 0, 0, 1], [ 1, 0, 0]], color=grey):
s3 := polygonplot3d([[ 1, 0, 0], [ 0, 1, 0], [ 0, 0,-1], [ 1, 0, 0]], color=grey):
s4 := polygonplot3d([[ 1, 0, 0], [ 0,-1, 0], [ 0, 0,-1], [ 1, 0, 0]], color=grey):
s5 := polygonplot3d([[-1, 0, 0], [ 0, 1, 0], [ 0, 0, 1], [-1, 0, 0]], color=grey):
s6 := polygonplot3d([[-1, 0, 0], [ 0,-1, 0], [ 0, 0, 1], [-1, 0, 0]], color=grey):
s7 := polygonplot3d([[-1, 0, 0], [ 0, 1, 0], [ 0, 0,-1], [-1, 0, 0]], color=grey):
s8 := polygonplot3d([[-1, 0, 0], [ 0,-1, 0], [ 0, 0,-1], [-1, 0, 0]], color=grey):
aA := arrow(< 1, 0, 0>, <-1, 1, 0>, shape=arrow, color=green, thickness=3):
bA := arrow(< 1, 0, 0>, <-1, 0, 1>, shape=arrow, color=blue, thickness=3):
cA := arrow(<1,0,0>+<-1,1,0>,<-1,0,1>-<-1,1,0>, shape=arrow, color=red, thickness=3):
display({s1,s2,s3,s4,s5,s6,s7,s8,aA,bA,cA},scaling=constrained,orientation=[-5,70,-70],viewpoint=circleleft);
 

Plot_2d
 

 

Let's define a, b, and c below so they are the same as the vectors plotted above. Then we'll use a cross product to compute the area of the triangular face surrounded by these arrows. We know that abs(Typesetting:-delayCrossProduct(a, b)) gives the area of the parallelogram spanned by a and b. 

So dividing by 2 should give the area of the triangle with sides a, b, VectorCalculus:-`+`(b, VectorCalculus:-`-`(a)). 

 

> a := <-1,1,0>;
b := <-1,0,1>;
c := b-a;

triangle_area := Norm(a &x b)/2;
 

 

 

 

Vector[column](%id = 18446744078120746150)
Vector[column](%id = 18446744078120746270)
Vector[column](%id = 18446744078120738934)
`+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2))))) (28)
 

 

Multiplying by 8 (since there are 8 faces on the octahedron) gives us the surface area of the octahedron. 

 

> surface_area := 8*triangle_area;
 

`+`(`*`(4, `*`(`^`(3, `/`(1, 2))))) (29)
 

 

Example: Let P = (1, 2, 0), Q = (1, -1, 0), and R = (-1, -1, -2). Let's find the equation of the plane passing through P,Q, and R. First, define u to be the vector from P to Q and v to point from P to R. Then n = Typesetting:-delayCrossProduct(u, v)is normal to the plan. So our desired equation is Typesetting:-delayDotProduct(n, VectorCalculus:-`+`(x, VectorCalculus:-`-`(P))) = 0.  

 

> P := <1,2,0>;
Q := <1,-1,0>;
R := <-1,-1,-2>;

u := Q-P;
v := R-P;

n := u &x v;

planeEqn := n.(<x,y,z>-P)=0:
 

 

 

 

 

 

Vector[column](%id = 18446744078120740014)
Vector[column](%id = 18446744078120740134)
Vector[column](%id = 18446744078120740254)
Vector[column](%id = 18446744078120741094)
Vector[column](%id = 18446744078120741934)
Vector[column](%id = 18446744078120742294) (30)
 

 

Let's also find the equation of the normal line through Q. This passes through Q and is parallel to n. 

 

> r := t -> Q + n*t:
'r(t)' = r(t);
 

r(t) = Vector[column](%id = 18446744078120736638) (31)
 

 

Now let's plot all of these together. 

 

> planePlot := plot3d(solve(planeEqn,z),x=-2..2,y=-2..4):
linePlot := spacecurve(r(t),t=-1/2..3/2,color=black,thickness=3):
uPlot := arrow(P,u,color=green):
vPlot := arrow(P,v,color=blue):
nPlot := arrow(P,n,color=red):
display({planePlot,linePlot,uPlot,vPlot,nPlot},axes=boxed,scaling=constrained,orientation=[-165,-5,-155],viewpoint=circleleft);
 

Plot_2d
 

 

Example: Consider the planes VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(2, x), VectorCalculus:-`-`(VectorCalculus:-`*`(3, y))), VectorCalculus:-`-`(z)) = 5 and VectorCalculus:-`+`(VectorCalculus:-`+`(x, VectorCalculus:-`*`(2, y)), VectorCalculus:-`*`(3, z)) = 4. First, let's find the angle between these planes.       

 

> restart;
with(VectorCalculus):
with(plots):

n[1] := <2,-3,-1>;
n[2] := <1,2,3>;

arccos(n[1].n[2]/(Norm(n[1])*Norm(n[2])));
 

 

 

Vector[column](%id = 18446744078108598390)
Vector[column](%id = 18446744078108598630)
`+`(`*`(`/`(2, 3), `*`(Pi))) (32)
 

 

But this angle is bigger than `^`(90, o) so we must need its supplement: VectorCalculus:-`+`(Pi, VectorCalculus:-`-`(VectorCalculus:-`*`(VectorCalculus:-`*`(2, `/`(1, 3)), Pi))) = VectorCalculus:-`*`(Pi, `/`(1, 3)). 

 

Alternatively, we could just swap out one of the norm vectors with its negation. This flips the dot product from a negative number (obtuse angle) to a positive number (acute angle). Even better, why not take the absolute value of the dot product to guarantee we have the desired acute angle? 

 

> theta := arccos(abs(n[1].n[2])/(Norm(n[1])*Norm(n[2])));
 

`+`(`*`(`/`(1, 3), `*`(Pi))) (33)
 

 

Next, let's find the line of intersection (where these planes intersect) and then parameterize this line. To do this we need to solve the simultaneous system of equations: 

 

> solve({2*x-3*y-z=5,x+2*y+3*z=4});
 

{x = `+`(`/`(22, 7), `-`(z)), y = `+`(`/`(3, 7), `-`(z)), z = z} (34)
 

 

Naturally we replace z with t and get a parametrization of our line. 

 

> r := t -> <22/7-t,3/7-t,t>:
'r(t)' = r(t);
 

r(t) = Vector[column](%id = 18446744078120218982) (35)
 

 

Finally, let's plot both planes and their line of intersection in the same plot. To use plot3d we need to solve the plane equations for z. We had to play around with the domain of t in spacecurve until everything looked nice. For this parametrization a range: t = 0 .. 6 seems to do the job. 

 

> solve(2*x-3*y-z=5,z);
solve(x+2*y+3*z=4,z);

plane1 := plot3d(-5+2*x-3*y,x=-5..2,y=-5..2,color=gray):
plane2 := plot3d(4/3-1/3*x-2/3*y,x=-5..2,y=-5..2,color=gray):
intLine := spacecurve(r(t),t=0..6,thickness=3,color=blue):
display({plane1,plane2,intLine},viewpoint=circleleft);
 

 

 

`+`(`-`(5), `*`(2, `*`(x)), `-`(`*`(3, `*`(y))))
`+`(`/`(4, 3), `-`(`*`(`/`(1, 3), `*`(x))), `-`(`*`(`/`(2, 3), `*`(y))))
Plot_2d
 

 

Example: Consider the line passing through the points P and Q and the line passing through the points R and S (P,Q,R and S defined below). Let v be the vector pointing from P to Q and w be the vector pointing from R to S.  

 

> P := < 1, 0,-2>;
Q := <-1, 1, 3>;
R := < 2,-2, 1>;
S := <-4, 4, 5>;

v := Q-P;
w := S-R;
 

 

 

 

 

 

Vector[column](%id = 18446744078120220902)
Vector[column](%id = 18446744078120221022)
Vector[column](%id = 18446744078120221142)
Vector[column](%id = 18446744078120221262)
Vector[column](%id = 18446744078120222102)
Vector[column](%id = 18446744078120214766) (36)
 

 

Next, we will fill in the parametrizations of the lines. The first line passes through P and Q and the second through R and S. The first parametrization starts at P (i.e. r[1](0) = P) and the second parametrization starts at R (i.e. r[2](0) = R). In addition, we have chosen parameterizations such that they go from P to Q and R to S (i.e. we use the vectors v and w as direction vectors). 

 

The plot of these lines shows that they intersect (so they lie in a common plane). I have given a parametrization of the plane which passes through P, Q, R, and S and called it r[3](s, t). 

 

> r[1] := t -> P + v*t:
'r[1](t)' = r[1](t);

r[2] := t -> R + w*t:
'r[2](t)' = r[2](t);

r[3] := (s,t) -> P + s*v + t*w:
'r[3](s,t)' = r[3](s,t);
 

 

 

r[1](t) = Vector[column](%id = 18446744078120215486)
r[2](t) = Vector[column](%id = 18446744078120216206)
r[3](s, t) = Vector[column](%id = 18446744078120217526) (37)
 

> line1 := spacecurve(r[1](t),t=-2..2,thickness=3,color=blue):
line2 := spacecurve(r[2](t),t=-2..2,thickness=3,color=green):
plane := plot3d(r[3](s,t),s=-2..2,t=-2.5..1.5,color=grey,transparency=0.5):
display(line1,line2,plane,scaling=constrained,axes=boxed,viewpoint=circleleft);
 

Plot_2d
 

 

Let's find the point of intersection. We need r[1](t) = r[2](s), but Maple is picky about working with vectors. So we'll need to convert these vector valued functions to a list of expressions. Also, to make life easier we'll solve the equivalent equation VectorCalculus:-`+`(r[1](t), VectorCalculus:-`-`(r[2](s))) = 0.  

 

> solve(convert(r[1](t)-r[2](s),list));

r[1](1) = r[2](1/2);
 

 

{s = `/`(1, 2), t = 1}
Vector[column](%id = 18446744078120208374) = Vector[column](%id = 18446744078120209214) (38)
 

 

The point of intersection is (-1,1,3). 

 

 

Finally, let's plot the line segments PQ and PR along with the triangular region whose vertices are PQR. 

 

Notice that "VectorCalculus:-`+`(P, VectorCalculus:-`*`(VectorCalculus:-`+`(Q, VectorCalculus:-`-`(P)), t))" where `and`(`<=`(0, t), `<=`(t, 1)) gives the line segment from P to Q [we start at P and then move along the vector pointing from P to Q -- that is -- "Q-P"]. Likewise "VectorCalculus:-`+`(P, VectorCalculus:-`*`(VectorCalculus:-`+`(R, VectorCalculus:-`-`(P)), t))" where `and`(`<=`(0, t), `<=`(t, 1)) gives the line segment pointing from P to R.  

 

The plane containing P, Q, and R can be parametrized by "VectorCalculus:-`+`(VectorCalculus:-`+`(P, VectorCalculus:-`*`(VectorCalculus:-`+`(Q, VectorCalculus:-`-`(P)), s)), VectorCalculus:-`*`(VectorCalculus:-`+`(R, VectorCalculus:-`-`(P)), t))". However, if we restrict our parameters sand t so that `and`(`<=`(0, s), `<=`(s, 1)) and `and`(`<=`(0, t), `<=`(t, 1)), then we will plot the whole parallelogram spanned by the vectors Q-P and R-P (based at point P). Since we only want the triangle, we need to stop along the edge which correpsponds to the vector R-Q. Notice that the parametrization for the plane is "VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(P, VectorCalculus:-`+`(VectorCalculus:-`+`(1, VectorCalculus:-`-`(s)), VectorCalculus:-`-`(t))), VectorCalculus:-`*`(Q, s)), VectorCalculus:..." so if we are to range between R [t=1, s=0] and Q [t=0, s=1], it seems reasonable to demand that "VectorCalculus:-`+`(VectorCalculus:-`+`(1, VectorCalculus:-`-`(s)), VectorCalculus:-`-`(t)) = 0" so P is not involved. This gives us the bound we're looking for: "t = VectorCalculus:-`+`(1, VectorCalculus:-`-`(s))". 

 

> line1 := spacecurve(P+(Q-P)*t,t=0..1,thickness=3,color=blue):
line2 := spacecurve(P+(R-P)*t,t=0..1,thickness=3,color=green):
plane := plot3d(P+(Q-P)*s+(R-P)*t,s=0..1,t=0..1-s,color=grey,transparency=0.5):
display(line1,line2,plane,scaling=constrained,axes=boxed,viewpoint=circleleft);
 

Plot_2d