Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2008-09-24 11:28:25

ybenaabud
Member
Registered: 2008-09-24
Posts: 2

matrix rotation from a vactor 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

Offline

#2 2008-09-25 09:35:33

ybenaabud
Member
Registered: 2008-09-24
Posts: 2

Re: matrix rotation from a vactor 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.

Offline

Board footer

Powered by FluxBB