#### Archived

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.

## 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 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.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.

##### Share on other sites
Hello

Take a look at this post, I am sure you will find it really good!
http://www.gamedev.net/community/forums/topic.asp?topic_id=63504

Regards!
Oscar

##### Share on other sites
wow, thanks. I got some new ideas.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
12

• 14
• 9
• 22
• 9
• 31
• ### Forum Statistics

• Total Topics
632618
• Total Posts
3007480
• ### Who's Online (See full list)

There are no registered users currently online

×