Find the Euclidean projection of $x_0$ on a hyperplane $C = \{x | a^Tx = b\}$.
My thoughts: We can view the point as a vector from the origin. The projection of a vector to the line is a multiple of the line $tx$. From the right triangle formed by the line and the vector we can say that $x^t(x_0-tx), t = \frac{x^tx_0}{|x|_2^2}$. So, the projection is $tx = \frac{x^tx_0}{|x|_2^2}x$.
However, the solution of the problem is $x_0+\frac{(b_0-a^Tx_0)}{|a|_2^2}a$.
A similar question that I don't understand is the projection of a point $x_0$ to the halfspace $C=\{x|a^Tx \le b\}$.
I think I got it. Let $x \in C$. Let's find the projection of a vector $x_0-x$. By the same logic as in my question the projection is a sum multiple of the line $ta$. Then from the right triangle we get $a^t(x_0-x-ta) = \frac{a^t(x_0-x)}{|a|_2^2}$. So, the projection itself is $ta = \frac{a^t(x_0-x)}{|a|_2^2}a$. However, we does not want the projection of a vector $(x_0-x)$ we seek the projection of a point $x_0$. From the right triangle it is known that $x_0-x = (P_C(x_0)-x_0) + \frac{a^t(x-x_0)}{|a|_2^2}a$. Where $P_C(x_0)$ is the projection of a point $x_0$ to the set $C$. Therefore, $P_C(x_0) = x + \frac{a^t(x-x_0)}{|a|_2^2}a = x + \frac{b-a^tx_0}{|a|_2^2}a$.
However, as you can see the answers do not coincide fully. Why? Did I make mistake?