RE: Plotting Intersecting Planes

• To: mathgroup at smc.vnet.net
• Subject: [mg27191] RE: [mg27165] Plotting Intersecting Planes
• From: "David Park" <djmp at earthlink.net>
• Date: Fri, 9 Feb 2001 03:10:35 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Heath,

eqn1 = 3*x - 2*y + 4*z == 3;
eqn2 = 2*x - 4*y + 3*z == 1;
eqn3 = x - 3*y + 2*z == 5;

How we make the plot depends upon whether all three planes intersect or
whether two or more of them are parallel. In your case, they all intersect
and that simplifies matters since we can then plot over a balanced range
about the intersection and get a good picture.

Find the point of interesection of the three planes.

Solve[{eqn1, eqn2, eqn3}][[1]]
center = {x, y, z} /. %
{x -> -15, y -> 2, z -> 13}
{-15, 2, 13}

Find the normals to each of the planes. The normals are just the
coefficients of the variables in the equations.

{n1, n2, n3} = Coefficient[First[#], {x, y, z}] & /@ {eqn1, eqn2, eqn3}
{{3, -2, 4}, {2, -4, 3}, {1, -3, 2}}

This is a pure function which will calculate a unit vector from a vector.
Having things in terms of unit vectors gives us a better control of our plot
range and scale for the plot.

unit = #1/Sqrt[#1 . #1] & ;

To parameterize one of the planes, say plane1 that corresponds to eqn1, we
find a vector that is perpendicular to n1 and a vector that is perpendicular
to n1 and the vector we just found. Since the normals form an independent
set of vectors, we could use

{Cross[n1, n2], Cross[n1, Cross[n1, n2]]}
{{10, -1, -8}, {20, 64, 17}}

as two orthogonal directions which span the first plane. We can then
parameterize the three planes, changing our spanning vectors into unit
vectors, as

plane1[u_, v_] = center + {u, v} . unit /@ {Cross[n1, n2],
Cross[n1, Cross[n1, n2]]}
{-15 + 2*Sqrt[5/33]*u + 4*Sqrt[5/957]*v, 2 - u/Sqrt[165] +
(64*v)/Sqrt[4785],
13 - (8*u)/Sqrt[165] + (17*v)/Sqrt[4785]}

plane2[u_, v_] = center + {u, v} . unit /@ {Cross[n2, n3],
Cross[n2, Cross[n2, n3]]}
{-15 + u/Sqrt[6] + (11*v)/Sqrt[174], 2 - u/Sqrt[6] + (7*v)/Sqrt[174],
13 - Sqrt[2/3]*u + Sqrt[2/87]*v}

plane3[u_, v_] = center + {u, v} . unit /@ {Cross[n3, n1],
Cross[n3, Cross[n3, n1]]}
{-15 - (8*u)/(3*Sqrt[13]) - (25*v)/(3*Sqrt[182]),
2 + (2*u)/(3*Sqrt[13]) - (23*v)/(3*Sqrt[182]),
13 + (7*u)/(3*Sqrt[13]) - 11/3*Sqrt[2/91]*v}

We can check that our parameterizations our correct by

Simplify[eqn1 /. Thread[{x, y, z} -> plane1[u, v]]]
True

with similar checks for the other two planes.

Let's also plot the intersection lines. Cross[n1,n2] is a vector that is
perpendicular to n1 and thus lies in plane1. It is also perpendicular to n2
and thus lies in plane2. Hence it lies along the intersection of plane1 and
plane2. Hence we can parameterize our three intersection lines as:

line12[t_] = center + t*unit[Cross[n1, n2]]
{-15 + 2*Sqrt[5/33]*t, 2 - t/Sqrt[165], 13 - (8*t)/Sqrt[165]}

line23[t_] = center + t*unit[Cross[n2, n3]]
{-15 + t/Sqrt[6], 2 - t/Sqrt[6], 13 - Sqrt[2/3]*t}

line31[t_] = center + t*unit[Cross[n3, n1]]
{-15 - (8*t)/(3*Sqrt[13]), 2 + (2*t)/(3*Sqrt[13]), 13 + (7*t)/(3*Sqrt[13])}

I will use the following packages in the plotting.

Needs["Graphics`Colors`"]
Needs["Graphics`Animation`"]

If we want to plot our intersection lines in Red we could use the form of
ParametricPlot3D which allows us to specify plotting directives as a 4th
argument to the parametrization (a strange way of doing it, I must say.)

Join[line12[t], {Red}]
{-15 + 2*Sqrt[5/33]*t, 2 - t/Sqrt[165], 13 - (8*t)/Sqrt[165],
RGBColor[1., 0., 0.]}

So, plotting our planes, the intersection lines and the intersection point:

Block[{\$DisplayFunction = Identity}, With[{range = 5},
plot1 = ParametricPlot3D[Evaluate[{plane1[u, v], plane2[u, v],
plane3[u, v]}], {u, -range, range}, {v, -range, range},
PlotPoints -> {10, 10}]; plot2 = ParametricPlot3D[
Evaluate[{Join[line12[t], {Red}], Join[line23[t], {Red}],
Join[line31[t], {Red}]}], {t, -range, range}]]];
plot = Show[plot1, plot2, Graphics3D[{Black, AbsolutePointSize[6],
Point[center]}], Axes -> False, ImageSize -> 500];

I cut down the number of plot points for the planes because we don't need
too thick a mesh for planes. This will spin the graphics around for a better
view.

SpinShow[plot]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]
FrontEndTokenExecute["SelectionAnimate"]

Using my DrawingCube routines, available at my web site, you can combine the
various elements in a somewhat more natural manner.

Needs["Graphics`DrawingCube`"]
Needs["Graphics`ParametricDrawing3D`"]

plot =
With[{range = 5},
Show[Graphics3D[{
ParametricDraw3D[Evaluate[{plane1[u, v], plane2[u, v],
plane3[u, v]}], {u, -range, range}, {v, -range, range},
PlotPoints -> {10, 10}],
Red, ParametricDraw3D[
Evaluate[{line12[t], line23[t], line31[t]}], {t, -range, range}],
Black, AbsolutePointSize[6], Point[center]}],
AspectRatio -> Automatic,
PlotRange -> All, ImageSize -> 500]];

David Park

> -----Original Message-----
> From: heathwatts at my-deja.com [mailto:heathwatts at my-deja.com]
To: mathgroup at smc.vnet.net
> Sent: Thursday, February 08, 2001 4:41 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg27191] [mg27165] Plotting Intersecting Planes
>
>
> Hi,
> I cannot remember how to plot two or more linear equations. I'm trying
> to plot 3x-2y+4z==3, 2x-4y+3z==1, and x-3y+2z==5. I've solved the
> equations for z and tried Plot3D and ImplicitPlot3D to no avail. Please
> help.
> Thanks,
> Heath
>
>
> Sent via Deja.com
> http://www.deja.com/
>
>

```