|
-
September 24th, 2008, 01:11 PM
#1
Matrix to rotate a vector MA to MB
Hello,
i am working on a 3D project. some where in my program i need to draw a plan that is perpendicular to a vector MB. for doing this i need to know the (x,y,z) of each voxel in this plan (a portion of the plan or window).
for this i need to make a marix that transform a well known vector MA (for exemple parallel to X axis) to a known vector MB of the same length. why ? because I will calculate the (x,y,z) of the plan perpendicular to X axis (witch is easy to calculate) and then multiplay by the matrix to obtain the (x,y,z) in the new plan (perpendicular to MB)
So i need a rotation matrix (because of the same origin M of the two vectors). I think i can do only two rotations (on Y and Z axis) to obtain the new vector MB.
think you
the programmer
-
September 25th, 2008, 04:34 PM
#2
Re: Matrix to rotate a vector MA to MB
To find a matrix that transform a vector MA to a vector MB you can try this:
1) If MA and MB are not unit length, normalize it.
2) Calculate the dot product of MA and MB, this will give the cosinus of the angle between MA and MB. To get the angle, take the arccos of the result.
3) Calculate the cross product of MA and MB, this will give a vector for the axe of rotation.
4) Now we have an angle and a vector. Then you can use the Rodrigues formula to calculate a rotation matrix to rotate MA to MB.
the programmer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|