How to find cos(X) sin(X) in a rotation when X is unknown

425 Views Asked by At

I'd like to perform rotation from one vector to the other. I have two formulaes to get sin(X) and cos(X), X being the rotation angle, but I can't see where they come from :

denom = a * a + b * b;
sin(X) = ( b * ta - a * tb ) / denom;
cos(X) = ( a * ta + b * tb ) / denom;

Can somebody help me to clear this out ?

Thanks

1

There are 1 best solutions below

3
On BEST ANSWER

The rotation would be $$ \begin{pmatrix}t_a\\t_b\end{pmatrix}= \begin{pmatrix}\cos X&\sin X\\-\sin X&\cos X\end{pmatrix}\begin{pmatrix}a\\b\end{pmatrix}$$ or $t_a=a\cos X+b\sin X$, $t_b=b\cos X-a\sin X$. Solving for $\sin X, \cos X$ gives the equations you have