# Orthogonal projection and reflection matrix

Let $A$ represent orthogonal projection onto the plane $x+y+z=0$ and $B$ represent the reflection in the plane $x+y+z=0$. Determine $3\times 3$ matrix $A$ and $B$. All I know is that $A^2=A$. So in general how would you determine $A$ and $B$ if they are projection/reflection in the plane $ax+by+cz=0$?

To calculate the projection matrix you need to calculate the projection of the canonical basis $\{ e_1=(1,0,0), e_2=(0,1,0), e_3=(0,0,1)\}$ and we know that the plane $P=\{ax+by+cz=0 \}$ is equal to $Vect\{ v_1=(-b,a,0), v_2=(-c,0,a) \}$ in this case we need an orthonormal basis so we construct it by Gram-Schmidt process and we have $$P=Vect\{f_1=(\frac{-b}{\sqrt{a^2+b^2}},\frac{a}{\sqrt{a^2+b^2}},0); f_2=(\frac{-a^2c}{\alpha},\frac{-abc}{\alpha},\frac{a^3+ab^2-bc}{\alpha})\}$$ With $\alpha=\sqrt{(a^2c)^2+(abc)^2+(a^3+ab^2-bc)^2}$ a normalisation constant.

So the projection of $X=(x,y,z)$ on $P$ is equal to $<X,f_1>f_1 +<X,f_2>f_2$ so in this case :

$$\left\{ \begin{array}{c} A(e_1)&=&<e_1,f_1>f_1 +<e_1,f_2>f_2&=&\frac{-b}{\sqrt{a^2+b^2}} f_1 -\frac{a^2c}{\alpha} f_2&=&(\frac{b^2}{a^2+b^2}+\frac{(a^2c)^2}{\alpha^2},\frac{-ab}{a^2+b^2}-\frac{a^3 bc^2}{\alpha^2},\frac{-a^2c(a^3+ab^2-bc)}{\alpha^2})\\ A(e_2)&=&<e_2,f_1>f_1 +<e_2,f_2>f_2&=&\frac{a}{\sqrt{a^2+b^2}} f_1-\frac{abc}{\alpha}f_2 &=&(\frac{-ab}{a^2+b^2}+\frac{a^3 bc^2}{\alpha^2},\frac{a^2}{a^2+b^2}+\frac{(abc)^2}{\alpha^2},\frac{-abc(a^3+ab^2-bc)}{\alpha^2})\\ A(e_3)&=&<e_3,f_1>f_1 +<e_3,f_2>f_2&=& \frac{a^3+ab^2-bc}{\alpha} f_2&=&(\frac{-a^2c(a^3+ab^2-bc)}{\alpha^2},\frac{-abc(a^3+ab^2-bc)}{\alpha^2},\frac{(a^3+ab^2-bc)^2}{\alpha^2}) \end{array}\right.$$ and finally the matrix is : $$A=\left( \begin{matrix} \frac{b^2}{a^2+b^2}+\frac{(a^2c)^2}{\alpha^2} & \frac{-ab}{a^2+b^2}+\frac{a^3 bc^2}{\alpha^2}& \frac{-a^2c(a^3+ab^2-bc)}{\alpha^2}\\ \frac{-ab}{a^2+b^2}-\frac{a^3 bc^2}{\alpha^2} &\frac{a^2}{a^2+b^2}+\frac{(abc)^2}{\alpha^2} &\frac{-abc(a^3+ab^2-bc)}{\alpha^2}\\ \frac{-a^2c(a^3+ab^2-bc)}{\alpha^2} &\frac{-abc(a^3+ab^2-bc)}{\alpha^2} &\frac{(a^3+ab^2-bc)^2}{\alpha^2} \end{matrix}\right)$$

For $B$ we know that $B=2A-I_3$ so : $$B=\left( \begin{matrix} \frac{2b^2}{a^2+b^2}+\frac{2(a^2c)^2}{\alpha^2}-1 & \frac{-2ab}{a^2+b^2}+\frac{2a^3 bc^2}{\alpha^2}& \frac{-2a^2c(a^3+ab^2-bc)}{\alpha^2}\\ \frac{-2ab}{a^2+b^2}-\frac{2a^3 bc^2}{\alpha^2} &\frac{2a^2}{a^2+b^2}+\frac{2(abc)^2}{\alpha^2}-1 &\frac{-2abc(a^3+ab^2-bc)}{\alpha^2}\\ \frac{-2a^2c(a^3+ab^2-bc)}{\alpha^2} &\frac{-2abc(a^3+ab^2-bc)}{\alpha^2} &\frac{2(a^3+ab^2-bc)^2}{\alpha^2}-1 \end{matrix}\right)$$

Here is a geometric way to do it. If $\hat{n}$ is a normal vector to your plane, then projection of a vector $v$ onto your plane is accomplished by subtracting from $v$ its component along $n$, ie $A v = v - \hat{n} (\hat{n} \cdot v)$. Note that $\hat{n}(\hat{n} \cdot v ) = \hat{n} \hat{n}^T v$, which gives you a formula $A = I - \hat{n} \hat{n}^T$.

Similarly, reflection is inverting the component of $v$ along $n$, ie $B v = v - 2 \hat{n} ( \hat{n} \cdot v)$. ( You can check that $(B v) \cdot \hat{n} = - v \cdot \hat{n}$ ) . There is a similar formula for $B$.

So now you have to find $\hat{n}$, I trust you can do that.

Method 1: to understand what is going on. Choose a basis for $\def\R{{\Bbb R}}\R^3$ consisting of two vectors in the plane and one perpendicular to the plane, for example, $$S=\{(1,-1,0),\,(0,1,-1),\,(1,1,1)\}\ .$$ Then for the projection $P$ we have $$P(1,-1,0)=(1,-1,0)\ ,\quad P(0,1,-1)=(0,1,-1)\ ,\quad P(1,1,1)=(0,0,0)\ .$$ So the matrix of the projection with respect to the basis $S$ is $$M=\pmatrix{1&0&0\cr0&1&0\cr0&0&0\cr}\ ,$$ and I expect you have learned how to convert this into the matrix $A$ of $P$ with respect to standard bases. For the reflection, exactly the same except that $$R(1,1,1)=-(1,1,1)\ .$$

Method 2: just using formulae. Find an orthonormal basis for the plane, for example, $$\{\,\tfrac1{\sqrt2}(1,-1,0),\,\tfrac1{\sqrt6}(1,1,-2)\,\}\ ;$$ let $Q$ be the matrix with these vectors as its columns; then $A=QQ^T$. Let $\bf n$ be a column vector which is a unit normal to the plane; then $$B=I-2{\bf n}{\bf n}^T\ .$$

For the plane $ax+by+cz=0$, both methods will be the same except that the basis vectors and normal vector will be different.