Sign in to follow this  

Aligning to a normal

This topic is 3487 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.



Alternatively.

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.

KJM

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

Share this post


Link to post
Share on other sites

This topic is 3487 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this