Monday, 15 February 2010

math - Creating a rotation matrix based on two vectors -


When I pass in a vector (V), I am looking to create a rotation matrix (m) where M * [0, 0, 1] (next) = V .

I am doing this because I want to use the matrix to use other vectors to multiply them in the local place (not sure that this is the correct word but hopefully you Understand)

  V = [0, 1, 0] m =? Result = M * V = [0, 0, -1]   

So if [0,0,1] becomes 90 degrees upwards [0,1,0] After multiplying by M ... what is M ?

Three-dimensional rotation is difficult to think about and difficult to interpret in text is. However, according to estimates of a set of three-dimensional axes, the shape of your left hand is possible. See the following Wikipedia page describing Fleming's left hand rule; In particular, look at the second diagram, in which the fingers marked as I , b , and f :

Make the same composition with your own hands, and instead of labeling the fingers i , b , and f , call them < Em> x , y , and z apart from this, we would say that at which point these three fingers meet the palm of your hand, the origin, point (0), and basically one of these fingers / thumbs On the side of the positive direction

Vector V = (0 0 0) is a point with your pointing finger (which we have called y ). We want to rotate this point as the point (0 -1). This point sits on the z axis (thumb), but it is negative, so under the tip of the thumb in the direction of the root, one unit sits "down".

So, to rotate the point (0 0) (0 -1 -1), we need to rotate it around the x axis (the middle of your middle finger) . Imagine putting a compact disc on your middle finger, from which it sits on the plane defined by your director finger and thumb. ( x , y ) plane ??? And insert a mark on the disk one unit from its center Now imagine to align that mark with your index finger so that sitting on the mark point (0 to 0). You can rotate the disk around your middle finger so that sitting on the mark point (0-1 -1). Therefore, the required rotation is a rotation around the x axis.

The following Wikipedia page gives you the equation for it. x is the matrix for the rotation around the axis:

  / 0 0 | 0 cos θ -sin θ | If you use your right hand to rotate the disk, then the matrix is ​​defined so that a negative value for θ matches the clockwise speed with its right hand (and vice versa for a positive value) The angle we need to rotate is the negative quarter turning and the required matrix:  
  / 1 0 \ | 0 0 1 | \ 0-0 /   

Remember that Angels can be expressed in degrees or radians, so if you implement more general rotation in the code, then you have to see this What is the hope of your math library?

No comments:

Post a Comment