Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Creating a Rotation Matrix from a Plane Normal

This topic is 6180 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post

Link to post
Share on other sites
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:

right.x right.y right.z
up.x up.y up.z
forward.x forward.y forward.z

(might have to be transposed, depends on how you use the matrix)

I hope that helped.

Share this post

Link to post
Share on other sites

Take a look at this post, I am sure you will find it really good!


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!