Assume I have a vector $V_a$ that belongs to the plane $A$ defined by the normal $n_a$, which means that $V_a \cdot n_a = 0$.
Then assume that I projected $V_a$ onto a plane $B$ defined by its normal $n_b$ resulting in vector $V_b = V_a - (n_b \cdot V_a)n_b$.
If I know $V_b$, $n_a$ and $n_b$, how do I recover $V_a$? I initially thought that it would be as simple as projecting $V_b$ onto $A$, but a quick numerical test showed me that this isn't the case. Inverting the projection matrix also didn't work because $n_b$ is an null eigenvector.
Notes:
- I am interested in vector directions so all vectors are normalized
- Vectors are restricted to $\mathbb R^3$
- $n_a \cdot n_b \ne 0$
I figured it out!
Starting point:
$V_a - x.n_b = V_b$
Computing the dot product of both side of the equation with $n_a$ gives:
$V_a\cdot n_a - x.n_b\cdot n_a = V_b\cdot n_a$
The first term is zero so solving for $x$:
$x=-\frac{V_b\cdot n_a}{n_b\cdot n_a}$
Substituting in the first equation:
$V_a = V_b - \frac{V_b\cdot n_a}{n_b\cdot n_a}.n_b$