Given a normal vector in 3D-Space, how can I rotate the vector, such it points to a point in 3D-Space.
I tried couple of ways doing this, which ended up looking completely wrong.
Given a normal vector in 3D-Space, how can I rotate the vector, such it points to a point in 3D-Space.
I tried couple of ways doing this, which ended up looking completely wrong.
Let $e,f$ be the two edges of the triangle. Let's construct an orthonormal system: $e = normalize(e)$, $n = normalize(e\times f)$, $f = n \times e$, where $\times$ is the cross product. Now compute:
$$e' = e - \frac{e \cdot n'}{1+(n\cdot n')}(n+n')$$
$$f' = f - \frac{f \cdot n'}{1+(n\cdot n')}(n+n')$$
Then the rotation matrix is:
$$R = \begin{bmatrix} e' & f' & n'\end{bmatrix} \begin{bmatrix} e^T \\ f^T \\ n^T \end{bmatrix}.$$
Note that the computation of $e'$ and $f'$ breaks for $n' = -n$.