Laboratory 3
Projections, Lines, and Planes

Introduction

In this lab, we explore the properties of projections. We shall also study equations of lines and planes in space.

Example 3.1  Projections

Let (OverVector[a]) and (OverVector[b]) be two nonzero vectors (two or three dimensional). The projection of (OverVector[b]) onto (OverVector[a]) is the vector that has the same direction as (OverVector[a]) and together with (OverVector[b]) forms a right triangle. The scalar projection of (OverVector[b]) onto (OverVector[a]) is defined to be the magnitude of the vector projection, and is called the component of (OverVector[b]) along (OverVector[a]). We can derive a formula that gives us the component of one vector in the direction of another. Indeed, let (OverVector[a]) and (OverVector[b]) be two nonzero vectors in the plane.



Then the projection of the vector (OverVector[b]) in the direction of (OverVector[a]) is the black vector in the figure above, while the component of (OverVector[b]) in the direction of (OverVector[a]) is the length of the black vector. Basic trigonometry tells us that the length of the black vector is the same as ||(OverVector[b])|| cos θ; however we know that we can find cos θ from the dot product as  cos θ=(((OverVector[a])·(OverVector[b]))/(||(OverVector[a])|| ||(OverVector[b])||)). Thus the component of (OverVector[b]) in the direction of (OverVector[a]) is  (((OverVector[a])·(OverVector[b]))/(||(OverVector[a])||)). For convenience, we define the following command to obtain the component of the vector (OverVector[b]) in the direction (OverVector[a]).

comp[b_,a_]:=a.b/Sqrt[a.a]

The vector projection of (OverVector[b]) onto (OverVector[a]) is the vector that points in the same direction as (OverVector[a]), but whose length is the component of (OverVector[b]) in the direction of (OverVector[a]). Since the vector ((OverVector[a])/(||(OverVector[a])||)) points in the same direction as (OverVector[a]) but has length 1, we can define the projection of (OverVector[b]) in the direction of (OverVector[a]) as follows.

proj[b_,a_]:=comp[b,a]a/Sqrt[a.a]

To see these ideas in action, let us set (OverVector[a])=(2,-4) and (OverVector[b])=(-3,-4). Then we can find the component of (OverVector[b]) in the direction of (OverVector[a]) and the projection of (OverVector[b]) in the direction of (OverVector[a]) as follows.

Clear[a,b]
a={2,-4};
b={-3,-4};
comp[b,a]
proj[b,a]

To see this geometrically, we once again load the following 2d and 3d vector drawing commands.

vector[a_,b_,c_:0]:=If[c==0,Return[Graphics[{Arrowheads[Medium],Arrow[{a,b}]}]],Return[Graphics[{Hue[c],Arrowheads[Medium],Arrow[{a,b}]}]]]
vector3d[a_,b_,c_:0]:=Module[{d},
d=Norm[b-a];
If[c==0,Return[Graphics3D[{Thick,Black,Line[{a,b}],Translate[Rotate[Scale[Table[{EdgeForm[],Polygon[{{.25Cos[j(Pi/6)],.25Sin[j(Pi/6)],0},{.25Cos[(j+1)(Pi/6)],.25Sin[(j+1)(Pi/6)],0},{0,0,1}}]},{j,0,11}],d/10,{0,0,0}],{{0,0,1},b-a}],(9b+a)/10]}]],
Return[Graphics3D[{Thick,Hue[c],Line[{a,b}],Translate[Rotate[Scale[Table[{EdgeForm[],Polygon[{{.25Cos[j(Pi/6)],.25Sin[j(Pi/6)],0},{.25Cos[(j+1)(Pi/6)],.25Sin[(j+1)(Pi/6)],0},{0,0,1}}]},{j,0,11}],d/10,{0,0,0}],{{0,0,1},b-a}],(9b+a)/10]}]]
]
]

We can then plot (OverVector[a]), (OverVector[b]), and the projection of (OverVector[b]) in the (OverVector[a]) direction as follows.

Show[{vector[{0,0},a,0.01],vector[{0,0},b,0.67],vector[{0,0},proj[b,a]]},Axes->True,PlotRange->Automatic,AspectRatio->Automatic]

Which vector is (OverVector[a]), which is (OverVector[b]), and which is the projection of (OverVector[b]) in the direction of (OverVector[a]) ?

The projection and component operations are also defined for vectors in three dimensions. Suppose that (OverVector[a])=(1,-1,5) and (OverVector[b])=(3,-2,2). Then we can find the projection and component of (OverVector[b]) in the direction of (OverVector[a]) as follows.

Clear[a,b]
a={1,-1,5};
b={3,-2,2};
comp[b,a]
proj[b,a]
Show[{vector3d[{0,0,0},a,0.01],vector3d[{0,0,0},b,0.67],vector3d[{0,0,0},proj[b,a]]},Axes->True,PlotRange->Automatic,ViewPoint->{6,2,2}]

Experiment 3.1

1.  Let (OverVector[a])=(5,2)  and (OverVector[b])=(2,3). Find the projection of (OverVector[b]) in the direction of (OverVector[a]), as well as the component of (OverVector[b]) in the direction of (OverVector[a]). Graph (OverVector[a]), (OverVector[b]), and the projection of (OverVector[b]) in the (OverVector[a]) direction, and label the results.

2. Let (OverVector[a])=(5,2,-4)  and (OverVector[b])=(2,3,-2). Find the projection of (OverVector[b]) in the direction of (OverVector[a]), as well as the component of (OverVector[b]) in the direction of (OverVector[a]). Graph (OverVector[a]), (OverVector[b]), and the projection of (OverVector[b]) in the (OverVector[a]) direction, and label the results.
	
3.  Let (OverVector[a])=(4,2)  and (OverVector[b])=(-2,3). Find the projection of (OverVector[b]) in the direction of (OverVector[a]), as well as the component of (OverVector[b]) in the direction of (OverVector[a]). Graph (OverVector[a]), (OverVector[b]), and the projection of (OverVector[b]) in the (OverVector[a]) direction, and label the results.

4. Let (OverVector[a])=(3,2,-4)  and (OverVector[b])=(2,2,-1). Find the projection of (OverVector[b]) in the direction of (OverVector[a]), as well as the component of (OverVector[b]) in the direction of (OverVector[a]). Graph (OverVector[a]), (OverVector[b]), and the projection of (OverVector[b]) in the (OverVector[a]) direction, and label the results

Example 3.2 Lines and Planes

3.2.1 Lines

Let L be the line in three dimensional space determined by a point (Subscript[P, 0])((Subscript[x, 0]),(Subscript[y, 0]),(Subscript[z, 0])) on the line and the direction vector (OverVector[v]) parallel to the line. Then any point P on the line has the form P=(Subscript[P, 0])+t (OverVector[v]) for some real number t.Suppose that we wanted to represent the line through the point (Subscript[P, 0])(1,-2,4) in the direction (OverVector[v])=(2,4,-4). An unknown point on this line P would have the form P(x,y,z), and would satisfy P=(Subscript[P, 0])+t (OverVector[v]). We can represent this in Mathematica as follows. First we define the points.

P={x,y,z};
P0={1,-2,4};
v={2,4,-4};

Our equation is then

P==P0+t*v

We used double equals "==" instead of "=" because we want to let Mathematica know that this equality is to hold for all values of t. As a consequence, we conclude that our line has the equations x=1+2t, y=-2+4t, z=4-4t. We can then plot the graph of this line with the aid of the Mathematica command ParametricPlot3D in the following fashion.

ParametricPlot3D[Evaluate[P0+t v],{t,-5,5},BoxRatios->Automatic,PlotRange->{{-10,10},{-10,10},{-10,10}},PlotStyle->{Thick}]

Note the use of the Mathematica command Evaluate in the argument of the ParametricPlot3D command.

3.2.2 Planes

A plane in three dimensional space determined by a point (Subscript[P, 0]) on the plane and a vector (OverVector[n]) normal to the plane, is described by the vector equation (P-(Subscript[P, 0]))·(OverVector[n])=0 where P is an arbitrary point on the plane. Suppose that we want to find the plane that passes through the point (Subscript[P, 0])(1,-2,1) and is normal to the vector (OverVector[n])=(1,-1/2,2). First we define the points.

P={x,y,z};
P0={1,-2,1};
n={1,-1/2,2};

Then we write the equation of the plane just as we did for the line, using double equals "==".

(P-P0).n==0

We can simplify the result using the command Simplify.

Simplify[(P-P0).n==0]

There are two ways we can draw the graph of the resulting plane. The first method is to use the command Plot3D. To apply this command, we first solve the equation of our plane for z.

Solve[(P-P0).n==0,z]

We can then see that z=(1/4) (8-2 x+y). We then plot the result.

Plot3D[(8-2 x+y)/4,{x,-10,10},{y,-10,10},BoxRatios->Automatic]

The command Plot3D works well provided the plane can be written as z=z(x,y), but not all planes can be written in this fashion. In particular, the equation of a plane whose normal vector is perpendicular to the z-axis can not be written in this fashion. There is an alternative however. We know that our plane has the equation x+2 z=4+(y/2). We can rewrite this as x-(y/2)+2z=4. Given any function f(x,y,z), we can plot the solution of f(x,y,z)=c by using a contour plot. The appropriate Mathematica command is called ContourPlot3D.

ContourPlot3D[x-y/2+2 z,{x,-10,10},{y,-10,10},{z,-10,10},Contours->{4},Axes->True,BoxRatios->Automatic]

Because we want to plot x-(y/2)+2z=4, we use the Contours->{4} option. In general, if we want to plot f(x,y,z)=c, we would use the option 
Contours->{c}. Note that the two planes we have generated are the same, even though the hatched lines on the planes are drawn differently.

3.2.3 Applications

Let us put all of these ideas together, and find the equation of the plane passing through the point P(1,2,3) and perpendicular to the line through P and the point Q(2,-1,-6). We shall also find the line through P and Q, and we shall also plot both the line and the plane on the same graph. First we name our points.

Clear[P,Q,T,n,A,B]
P={1,2,3};
Q={2,-1,-6};

Next we find the vector from P to Q. This is the direction vector for our line, and it is also the normal vector for our plane.

n=Q-P

Every point on our line has the form P+t (OverVector[n]) for some real number t.

P+t n

Thus the parametric form of our line is x=1+t, y=2-3t, z=3-9t. The graph of our line can then be found as before; we call the result A.

A=ParametricPlot3D[Evaluate[P+t n],{t,-10,10},BoxRatios->Automatic,PlotRange->{{-10,10},{-10,10},{-10,10}},PlotStyle->Thick]

If T(x,y,z) is in our plane, then (T-P)·(OverVector[n])=0, so the equation of the plane is

T={x,y,z};
(T-P).n==0

Thus, the equation of our plane is x-3y-9z=-32. We can graph this using either ContourPlot3D or Plot3D. We shall use the latter, and call the result B.

Solve[(T-P).n==0,z]

B=Plot3D[(32+x-3 y)/9,{x,-10,10},{y,-10,10},BoxRatios->Automatic]

We can show the both the plane and the line together using the Show command.

Show[A,B]

Experiment 3.2

1. Find the equation of the plane passing through the point P(-5,-3,-2) and perpendicular to the line through P and the point Q(-7,-4,6). Then find the equation of the line through P and Q, and plot both the plane and the line on the same graph.
	
2. Find the equation of the plane passing through the point P(2,1,1) and perpendicular to the line through P and the point Q(-2,1,4). Then find the equation of the line through P and Q, and plot both the plane and the line on the same graph.

Example 3.3 Intersection of Two Planes

Now we shall use the ideas of the previous two parts to find an equation for the line of intersection of the two planes given by 2x+z=1 and -x-y-2z=0.

Let (Subscript[(OverVector[n]), 1]) and (Subscript[(OverVector[n]), 2]) be normal vectors for each of the two planes. From the equations of the planes, we see that (Subscript[(OverVector[n]), 1])=(2,0,1) and (Subscript[(OverVector[n]), 2])=(-1,-1,-2). Notice that the normal vectors are not parallel, therefore the intersection of the planes must be a line. Any direction vector of the line of intersection must be orthogonal to the normal vector of each of the two planes. Thus the line of the intersection lies in both planes and is perpendicular to both (Subscript[(OverVector[n]), 1]) and (Subscript[(OverVector[n]), 2]). Consequently, (OverVector[n])=(Subscript[(OverVector[n]), 1])×(Subscript[(OverVector[n]), 2]) is a direction vector for the line of intersection.

Clear[n,n1,n2]
n1={2,0,1};
n2={-1,-1,-2};
n=n1\[Cross]n2

Now we need to find a point on both planes. Suppose (x,y,z) is a point on both planes; then we know that is must satisfy the equations of each plane. As a consequence,

	2x          +z=1, 
	-x-y-2z=0.

These are two equations in three variables, so we expect that there are an infinite number of solutions, one for each value of z. To see that this is the case, let us solve these two equations for x and y, and call the result sol.

sol=Solve[{2x+z==1,-x-y-2z==0},{x,y}]

We can then choose any value of z we wish, and use the above to find the corresponding values of x and y that solve the equations of both planes. For simplicity, let us set z=0. Then

sol /. z->0

We see that x=(1/2), y=-(1/2), and z=0 solves the equations of both planes, and hence lies on both planes. Let us call this point P.

P={1/2,-1/2,0}

Then every point on our line must have the form P+t (OverVector[n]) for some real number t.

P+t n

Finally, we plot the equations of the two planes, as well as the line on the same graph.

Solve[2x+z==1,z]
Solve[-x-y-2z==0,z]

plane1=Plot3D[1-2x,{x,-10,10},{y,-10,10},BoxRatios->Automatic];
plane2=Plot3D[(-x-y)/2,{x,-10,10},{y,-10,10},BoxRatios->Automatic];

Next, let L be the graph of our line. Note that we use the Hue option and the Thickness option so that our line is more easily seen in the combined graph.

L=ParametricPlot3D[{1/2+t,-1/2+3 t,-2 t},{t,-10,10},BoxRatios->Automatic,PlotRange->{{-10,10},{-10,10},{-10,10}},PlotStyle->{Red,Thick}];

Finally, we show the net result.

Show[{plane1,plane2,L},PlotRange->{{-10,10},{-10,10},{-10,10}}]

Experiment 3.3a

1. Find an equation for the line of intersection of two planes given by 3x-y+z=2 and 2x+y-2z=0. Check your work by graphing both planes and the line of intersection.

2. Find an equation for the line of intersection of two planes given by x-2y+z=0 and 2x+3y-2z=0. Check your work by graphing both planes and the line of intersection.

Experiment 3.3b

1.Find an equation for the line of intersection between the plane through A(5,1,-8), B(-6,2,7), C(3,9,1) and the plane through E(-8,1,1), F(4,-7,-3) and G(-5,-7,-1). Check your work by graphing both planes and the line of intersection. 
	
2.Find an equation for the line of intersection between the plane through A(1,2,3), B(3,2,1), C(-1,-2,2) and the plane through E(1,2,-3), F(2,3,1) and G(0,-2,-1). Check your work by graphing both planes and the line of intersection.

Example 3.4 Distance between a Point and a Plane

Let us find the distance between the point P(4,4,5) and the plane given by x+y+4z=8.



 Let R be the point in the plane so that the distance between the point P and the plane is the same as the distance between P and R. We would like to find the distance between P and R. We know that the vector from P to R points in the same direction as the normal vector to the plane, and we know that the normal is given by (OverVector[n])=(1,1,4). If we could find a point Q in the plane, then we see from the figure above that the distance from P to R will be exactly the component of the vector (OverVector[P Q]) in the direction of (OverVector[P R]). Since (OverVector[P R]) has the same direction as (OverVector[n]), it is sufficient to find the component of (OverVector[P Q]) in the direction of (OverVector[n]). To find our point in the plane, let x=0 and y=0, and obtain the point Q(0,0,2).
 
We begin by defining our variables.

Clear[P,Q,PQ,n]
P={4,4,5};
Q={0,0,2};
n={1,1,4};
PQ=Q-P

The distance we want is the component of (OverVector[P Q]) in the direction of (OverVector[n]), or more precisely the absolute value of the component of (OverVector[P Q]) in the direction of (OverVector[n]); we have to take the absolute value because (OverVector[n]) might point in the direction from P to R, or it might point in the opposite direction.

Abs[comp[PQ,n]]

We conclude that the distance from the point to the plane is ((10 (Sqrt[2]))/3).

Experiment 3.4

1.Find the distance between the point P(1,0,5) and the plane given by 2x+y-z=3.

2.Find the distance between the point P(1,5,-4) and the plane given by 3x-y+2z=3.

Example 3.5 Distance between a Point and a Line

Let us find the distance between the point P(2,-5,-2) and the line given by x=-1+4t, y=4t, and z=2+5t.



Let R be the point on the line closest to P. Choose another point Q on the line; we can do this by setting t=0 in the parametric form of the line; this gives us the point Q(-1,0,2). Because R is the point on the line closest to P, we know that the triangle P Q R is a right triangle. Thus, if we let (OverVector[a]) be the vector from P to Q, the distance from P to the line is ||(OverVector[a])||sin θ. Let (OverVector[v])=(4,4,5) be a vector that points in the same direction as the line; we know that it points in the same direction as the vector from R to Q; thus the angle θ in our figure is the angle between (OverVector[v]) and (OverVector[a]). However, we know that ||(OverVector[v])×(OverVector[a])||=||(OverVector[v])|| ||(OverVector[a])|| sin θ, so that the distance between the point and the line is ||(OverVector[a])|| sin θ=||(OverVector[v])×(OverVector[a])||/||(OverVector[v])||.

Clear[P,Q,a,v]
P={2,-5,-2};
Q={-1,0,2};
a=Q-P;
v={4,4,5};

Norm[v\[Cross]a]/Norm[v]

Thus the distance from the point to the line is (Sqrt[(2066/57)]) .

Experiment 3.5

1. Find the distance between the point P(3,-1,4) and the line given by x=5+3t, y=-2t, and z=2-4t.

2. Find the distance between the point P(2,-1,5) and the line given by x=-1+3t, y=1+2t, and z=2+4t.

Example 3.6 Distance between Two Skew Lines

Let us find the distance between the line through A(-4,-5,-3), B(0,-1,2) and the line through C(2,0,-3), D(3,4,3). We imagine a plane which contains the line CD, and is parallel to the line AB. The distance between the two lines then is just the distance from any point on the AB to the plane. 



Let us find the equation of the plane containing CD and parallel to AB. We know that this plane contains the line CD, so the normal to our plane must be perpendicular to the vector from C to D. On the other hand, because the plane is parallel to the line through A and B, we also know that the normal vector must be perpendicular to the vector from A to B. Thus, the normal vector for our plane is (OverVector[n])=(OverVector[A B]) × (OverVector[C D ]).

a={-4,-5,-3};
b={0,-1,2};
c={2,0,-3};
d={3,4,3};
AB=b-a;
CD=d-c;
n=AB \[Cross] CD

To find the distance between a point on the line AB and the plane, we simply need find a point on the line and a point on the plane, and then take the absolute value of the component of the vector between these two points in the direction of the normal. However, we know that A is on the line AB, while C is in the plane, so we can let our vector (OverVector[v]) be the vector from A to C.

v=c-a

The distance from the line to the plane is then just the absolute value of the component of (OverVector[v]) in the direction of (OverVector[n]).

Abs[comp[v,n]]

As the distance between the plane and the line is the same as the distance between the lines, we conclude that the distance between the two lines is (71/(Sqrt[521])).

Experiment 3.6

1.Find the distance between the line through A(2,-4,2), B(-5,3,1) and the line through C(1,3,-2), D(-5,-4,2).

2.Find the distance between the line through A(2,-4,2), B(-5,3,1) and the line through C(-1,3,4), D(-5,5,2).

Credits

These laboratories were created by Raouf Boules, Geoffrey Goodson, Ohoe Kim, Alexei Kolesnikov, Angel Kumchev and Michael O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of the authors. Non-commercial use is permitted, provided this credit section is retained.