# A problem about invariant subspaces

I need help with the following problem:

Let $H\subseteq\mathbb R^3$ be a plane with cartesian equation $x=y,$ and let $r$ be the straight line generated by $(1,1,2)$. Find an endomorphism $\phi$ of $\mathbb R^3$ such that $\phi(\mathbb R^3)=H$ and $\phi^2(\mathbb R^3)=r$.

Is there a standard way to choose such endomorphism $\phi$?

-

Extend $v_1 = (1,1,2)$ to a basis $\{v_1,v_2\}$ of $H$ and then to a basis $\{v_1, v_2, v_3\}$ of $\mathbb{R}^3$.
Take the endomorphism $\phi$ which maps $v_3$ to $v_2$, $v_2$ and $v_1$ to $v_1$.
Since $$\text{Range}(\phi)=H, \ \phi(H)=r,$$ and $$H=\{(x,y,z):\ x=y\}=\text{span}\{(1,1,0), \ (0,0,1)\}, \ r=\text{span}\{(1,1,2)\},$$ if we denote by $A$ of $\phi$ with respect to the canonical basis $e_1,e_2,e_3$ of $\mathbb{R}^3$, we have $$A=\left[ \begin{array}{ccc} a_1 & a_2 & a_3\cr a_1 & a_2 & a_3\cr b_1 & b_2 & b_3 \end{array} \right],$$ with $$b_1+b_2=2(a_1+a_2), \ b_3=2a_3.$$ Thus the matrix $A$ of $\phi$ has the form $$A=A(a,b,c,d)=\left[ \begin{array}{ccc} a & b & c\cr a & b & c\cr d & 2(a+b)-d & 2c \end{array} \right],$$ provided $(a,b,c,d) \in \mathbb{R}^4$ is such that $A(a,b,c,d) \ne 0$.