Demonstrating the intersection of two planes in space

This notebook accepts, in implicit form, the equation of 2 planes in 3-space. The equations of the planes to be used should be entered after the " :=" signs in the first  two lines of the input cell immediately below. Note that when the equations are entered a double equals sign "==" should be used. (See "equal" in the help index if you wish to know why.) The equations of the planes need to contain a z-term for the implementation to be effective, as each equation is solved for z so that it can be plotted using Mathematica's standard 3D plotting function.



Evaluating the first input cell plots each plane separately, then the two planes together, in the 20 by 20 by 20 cube with the origin at its centre. Evaluating the second of the two input cells below finds the parametric solution of the 2 by 3 system and plots it (separately) in  the same region used for the  three other plots. If the two planes are parallel you will see a number of messages, the last of which tells you that you have been trying to plot an empty set. You must evaluate the first of the two cells in order for the second input cell to be meaningful.



Enter the  equations for your two planes and evaluate (Shift-Enter)

eq1[x_,y_,z_]:= 2x+y-z==4

eq2[x_,y_,z_]:=2x+y-z==-10

f1[x_,y_]:=Replace[z,Flatten[Solve[eq1[x,y,z],z]]]

f2[x_,y_]:=Replace[z,Flatten[Solve[eq2[x,y,z],z]]]

p1:=Plot3D[{f1[x,y],Hue[.5,.2,1]},{x,-10,10},{y,-10,10},AxesLabel->{x,y,z},

	PlotRange->{-10,10},BoxRatios->{1,1,1},PlotLabel->eq1[x,y,z],

	ViewPoint->{3.253,0.647,0.669}]

p2:=Plot3D[{f2[x,y],Hue[.85,.4,1]},{x,-10,10},{y,-10,10},AxesLabel->{x,y,z},

	PlotRange->{-10,10},BoxRatios->{1,1,1},PlotLabel->eq2[x,y,z],

	ViewPoint->{3.253,0.647,0.669}]

Show[{p1,p2},PlotLabel->{eq1[x,y,z],eq2[x,y,z]}]

ReplaceAll[{x,y,z},Flatten[

Solve[{z==t,eq1[x,y,z],eq2[x,y,z]},{x,y,z}]]]

Graphics3D[ParametricPlot3D[ReplaceAll[{x,y,z},Flatten[

Solve[{z==t,eq1[x,y,z],eq2[x,y,z]},{x,y,z}]]],{t,-10,10},

PlotRange->{{-10,10},{-10,10},{-10,10}},BoxRatios->{1,1,1},PlotLabel->{eq1[x,y,z],eq2[x,y,z]},

	ViewPoint->{3.253,0.647,0.669}]]