Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
38 views

Projecting onto a plane versus projecting onto a line

Suppose we have a plane, a line lying in that plane, and a point not lying in the plane. To make things even easier, assume that the plane and the line both pass through the origin of R3\mathbb{R}^3 so that they are subspaces.

The process for finding a projection has to be done carefully because it is possible for the projection onto the plane and the projection onto the line to be different.

I will make an example and plot it.

Let's begin with the basic set-up: the plane, the line, and the point.

x, y, z = var('x y z') expr1 = -2*x + y -z == 0 v = vector([1,3,1]) b = vector([2,-2,-2]) Example = implicit_plot3d(expr1, [x,-3,3], [y,-3,3],[z,-3,3], color='red', opacity=.6) Example+= parametric_plot3d(x*v, [x,-1,1], color="blue") Example+= point(b.list()) show(Example)
3D rendering not yet implemented

Now I will use Sage to compute and then plot the projection of b onto the line. Note that the arrow from b to its projection is perpendicular to the line, but not to the plane.

A = matrix(QQ, 3,1, [1, 3, 1]) Pline = A*(A.transpose()*A).inverse()*A.transpose() bline = Pline*b ExLine = Example + point(bline.list(), size=10, color="black") + arrow(b, bline, color="purple") show(ExLine)
3D rendering not yet implemented

Now we shall compute and plot the projection of b onto the plane. Note that this gives a different point! This time, the arrow from b to its projection is perpendicular to the plane, but it doesn't even touch the line.

B = matrix(QQ, 1,3, [-2, 1, -1]).right_kernel().basis_matrix().transpose() # this finds a matrix B so that col(B) is equal to the plane Pplane = B*(B.transpose()*B).inverse()*B.transpose() bplane = Pplane*b ExPlane = Example + point(bplane.list(), size=10, color="black") + arrow(b, bplane, color="red") show(ExPlane)
3D rendering not yet implemented

I didn't intend for that purple arrow to show up in this plot. I don't know why it is there. Perhaps this is a bug?