# The Projection of a Vector onto a Plane

I want to find the orthogonal projection of the vector $$\vec y$$ onto a plane.

I have $$\vec y = (1, -1, 2)$$ and a plane that goes through the points \begin{align*}u_1 = (1, 0, 0) \\ u_2 = (1, 1, 1) \\ u_3 = (0, 0, 1) \end{align*} I started by finding the equation for the plane by calculating: $$\vec{PQ} = u_2 - u_1$$ and $$\vec{PR} = u_3 - u_1$$.
I then took the cross product between $$\vec{PQ}$$ and $$\vec{PR}$$ and got $$(1, -1, 1)$$. I used the cross product as coefficients $$a, b, c$$ in the equation: $$a(x - x_0) + b(y-y_0) + c(z-z_0) = 0$$

With this I got the plane equation to become $$x - y + z = 1$$.

Building on this, I went on to calculate the point where the vector $$\vec y$$ intersects the plane. I used $$(0, 0, 0)$$ as a starting point and $$(1, -1, 2)$$ as the endpoint.

$$r(t) = \{x_0, y_0, z_0\} + t\{x_1-x_0, y_1-y_0, z_1-z_0\} = (t, -t, 2t)$$

I inserted these parameters into the plane equation and got $$t = 1/4$$.

So the vector intersects the plane in $$(1/4, -1/4, 1/2)$$.

Now my task is to find the projection of the vector y onto the plane. My idea was to use the point of intersection together with the cross product to find a vector that is perpendicular to the plane. By using the point of intersection as the starting point and the cross product as the endpoint.

I could subtract y with this perpendicular vector and get the endpoint for the projection of y onto the plane, while also here using the point of intersection as the starting point.

Howevever, the resulting projection is not correct. Apparently, both the starting point and the end point has to be calculated differently.

I also tried using the Gram-Schmidt process to transform the base vectors $$u_1$$, $$u_2$$, $$u_3$$ into an ortogonal base. With this I tried to use the equation $$\vec y' = \frac{\vec y·u_1}{u_1·u_1}\cdot u_1 + \frac{\vec y·u_2}{u_2·u_2}\cdot u_2 + \frac{\vec y·u_3}{u_3·u_3}\cdot u_3$$ to find the projection but a bit surprisingly arrived back at the original vector y when doing this.

Tremendously grateful for any tips.

Image of my problem:

• Please use MathJax for typesetting math. – StubbornAtom Mar 18 at 14:08
• I have edited your question, please have a look if this reflects your original question. – Haris Gušić Mar 18 at 15:32
• The plane doesn’t pass through the origin—it’s not a subspace of $\mathbb R^3$—so applying G-S to the three vectors is nonsensical. In fact, you should end up with a basis for $\mathbb R^3$! If you’re going to orthogonalize anything, it should be $\overrightarrow{PQ}$ and $\overrightarrow{PR}$. – amd Mar 18 at 19:33
• It appears that you have a couple of fundamental conceptual errors here. What will you do if the vector doesn’t intersect the plane at all, say, if the plane were were $x-y+z=-1$ instead? – amd Mar 18 at 19:50

I think some confusion might have come from the way Mathematica creates a 2D plane out of the two given points.

By using that a vector that passes through a plane (y) can be broken down into the sum of a vector (normal) orthogonal to the plane (n) and a vector that runs parallell to the plane and is a projection (x).

y = n + x

(1, -1, 2) = (1, -1, 1) + (a, b, c)

Projection = Vektor - VektorNormal

Projection = (0, 0, 1)

I used this and calculated where the VektorNormal intersects the plane and used that as the starting point for the projection.

It seems reasonable that it could work and it looks like it might do the trick.

Although far from as elegant as Haris Gusic's calculations.

• I would say that the confusion lay not in Mathematica, but in your trying to start from the intersection of the vector and plane, which might not even exist in the first place. The correct “starting point,” as you put it, is where a line through the origin normal to the plane intersects it, i.e., from the closed point on the plane to the origin. – amd Mar 18 at 19:58
• I see. Thanks a lot for your great answers amd. – Olof Almqvist Mar 19 at 13:05

It looks like you’ve corrected the fundamental conceptual error that you were making in trying to find where $$\vec y$$ (really the line segment from the origin to $$\vec y$$) intersects the plane. That line of attack is suspect since there’s no a priori reason to believe that this intersection even exists.

However, once you’ve found an equation for the plane, the orthogonal projection of $$\vec y$$ onto this plane can be computed directly: it’s simply the foot of the perpendicular from $$\vec y$$ to the plane. A simple way to compute this point is to substitute $$\vec y+t\vec n$$, where $$\vec n$$ is normal to the plane, into the equation of the plane, and then solve for $$t$$: $$(1+t)-(-1-t)+(2+t)-1 = 3t+3 = 0,$$ so $$t=-1$$ and the orthogonal projection of $$\vec y$$ onto the plane is $$(0,0,1)$$.

You can instead compute the projection without finding an implicit Cartesian equation for the plane or even computing its normal by using the fact that the orthogonal projection of $$\vec y$$ onto the plane is the nearest point on the plane to $$\vec y$$. The plane can be parameterized by the affine combination $$\vec r(\alpha,\beta)=\alpha u_1+\beta u_2+(1-\alpha-\beta)u_3 = (\alpha+\beta,\beta,1-\alpha).$$ Minimizing the distance between $$\vec y$$ and $$\vec r$$ is equivalent to minimizing the square of the distance, namely $$(\alpha+\beta-1)^2+(\beta+1)^2+(1-\alpha-2)^2 = 2\alpha^2+2\alpha\beta+2\beta^2+3=\frac12(\alpha-\beta)^2+\frac32(\alpha+\beta)^2+3,$$ from which it’s obvious that the minimum is attained when $$\alpha=\beta=0$$, i.e., that the closest point to $$\vec y$$ is $$(0,0,1)$$.

• In Mathematica you can use the Minimize function on $\|\vec y-\vec r\|^2$ to compute $\alpha$ and $\beta$. – amd Mar 18 at 21:38