Creating a Rotation Matrix from a Plane Normal
I can create a plane, but I''d like to know how I can make a rotation matrix from its normal.
Why? I''m making a tank simulation and the terrain that it will travel on is rough.
Is there a way to take the x,y,z components of the normal vector, and plug it into the rotation matrix?
Well the key thing in such undertakings is the understanding of what the numbers in a rotation matrix mean. You can see the 3x3 matrix as consisting of three 3-dimensional vectors. These 3 vectors are of unit length and are all perpendicular to eachother. These axes are usually called forward, up and right. I''m assuming that the plane you speak of is the plane on which the tank is placed? If so, then the plane normal will be the tank''s up vector. This is not enough to create a rotation matrix however. You''ll also need either the right or the forward axis of the tank. The 3rd axis can be constructed by taking the crossproduct of the two. If you don''t have a forward/right vector, but you do have a yaw angle for the tank, then you can construct the matrix as follows: (the order might vary based on the ''handedness'' of your coordinate system)
forward.x = cos(yaw)
forward.y = 0
forward.z = sin(yaw)
up = plane.normal
right = up x forward
forward = right x up
(x means vector crossproduct)
Whatever method you use to create the three axes, you can create the rotation matrix by inserting the vectors into like this:
(might have to be transposed, depends on how you use the matrix)
I hope that helped.
forward.x = cos(yaw)
forward.y = 0
forward.z = sin(yaw)
up = plane.normal
right = up x forward
forward = right x up
(x means vector crossproduct)
Whatever method you use to create the three axes, you can create the rotation matrix by inserting the vectors into like this:
right.x right.y right.zup.x up.y up.zforward.x forward.y forward.z
(might have to be transposed, depends on how you use the matrix)
I hope that helped.
Dirk =[Scarab]= Gerrits
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement