Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
Are you familiar with the formulas for getting the lengths of the sides of a right triangle? The denom variable is a big hint. The numerators are not familiar to me, but I'm guessing they are due to a transformation matrix. –  abiessu Aug 14 '13 at 14:58
    
@abiessu, sure, but why keep it to the square ? Numerators are what puzzle me the most... –  CTZStef Aug 14 '13 at 15:01
    
I'm not certain on why it is still squared, but the formulas have been correctly identified in the answer by Hagen von Eitzen. –  abiessu Aug 14 '13 at 15:03

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
I'm trying to solve those, my algebra is quite rusty though. Will accept the answer as soon as I get it (may take ages). Thank you. –  CTZStef Aug 14 '13 at 15:23
    
OK done ! Thanks again. –  CTZStef Aug 14 '13 at 15:26
    
There is something that I don't quite underrstand : the rotation matrix seems to downscale vectors that it rotates, why is it so ? –  CTZStef Aug 19 '13 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.