Jump to content
  • Advertisement
Sign in to follow this  

Aligning to a normal

This topic is 3824 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 have a model of a plane which I want to use to represent a plane equation. I therefore have a point in the plane and a normal. I wish to make the model of the plane face in the same direction as the plane equation so I'm hoping someone can shed some light on how I can create a matrix from the normal I have so that it will rotate my model correctly. Thanks Marx!

Share this post

Link to post
Share on other sites
The axis of rotation is basically the cross product of the two vectors (normalised). The angle of rotation is the arcosine of the dot product of the vectors. Once you have the axis and angle, you can convert that to a matrix.

Share this post

Link to post
Share on other sites
One solution is.

If you have 3 direction vectors ( 3 sets of x,y,z's ), your normal being one of them, and the other two at right angles to that normal, then all componants of those direction vectors collectively go to make up an orientation matrix.

normal x , normal y , normal z

dir vec 1 x , dir vec 1 y , dir vec 1 z

dir vec 2 x , dir vec 2 y , dir vec 2 z

Multiplying all of the verticies in your un rotated model ( model reference frame ) by this orientation matrix will align the model exactly to the normal.

The models orientation, might be out by 90 degrees, depending on the order of those direction vectors in the matrix.

That will be a case of trial and error to find the correct order.

The three direction vectors that go to make up the orientation matrix are called direction cosines.


The Dot product of two vectors gives the angle between them. Using Acos ( arc cosine ) of the dot product gives the angle in degrees or radians, depending on the convention used by your programming language.

So, taking the dot product of the world up vector, and your normal gives you one angle, the dot product of your world left vector and your normal gives another and the dot product your world forward vector and your normal gives the third.

I think i'm right in saying that these three angles are euler angles, pitch, yaw and roll, which can be used to to rotate your model from it's un rotated model reference frame.

Although gimble lock might be a problem, as well as the order of rotations.

Perhaps someone else can clarify, as i'm unsure of this.

Also, i think the arc cosine of the normal elements gives it's euler angles.

As an example.
pitch = acos(normal z)
yaw = acos(normal y)
roll = acos(normal x)

But again i'm unsure, and someone would need to clarify.


[Edited by - K_J_M on May 27, 2008 2:00:57 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!