|
|
Margus Ramst wrote in message <3722715b.0@news.povray.org>...
>Hey all you math-enabled people!
>I need a macro to give me the rotation vector to rotate vector A to have
the
>same direction as vector B. I suspect I could do it myself, but could
>somebody spare me the head-ache?
Interrupt me if I am wrong ;-) but do I understand you correctly?
You want to rotate a vector such, that it points in the same direction as
some other vector?
If so, I don't see the need for any rotational math. I would do it like
this:
Compute the length of vector A.
lengthA = sqrt(Ax*Ax + Ay*Ay + Az*Az)
Normalize B to length 1. (B')
lengthB = sqrt(Bx*Bx + Ay*Ay + Az*Az)
B' = [ Bx/lengthB By/lengthB Bz/lengthB ]
Multiply it with the length of A (B'')
B''= [ B'x*lengthA B'y*lengthA Bz*lengthA ]
B'' is now the same direction as B and with the length of A.
All in one formula:
[ Bx / lengthB * lengthA ]
[ ]
B'' = [ By / lengthB * lengthA ]
[ ]
[ Bz / lengthB * lengthA ]
(where lengthA and lengthB as given above)
Is that what you want?
Johannes.
P.S. So, I'm showing my math in public? I *really* hope I got it right ;-)
Post a reply to this message
|
|