Take the cross product between them to get the axis of rotation, and
take the dot product to get the cosine of the angle of rotation. Then
construct a rotation matrix with that angle and axis.
Watch out for the cases where the normals are (nearly) identical or one
is the negative of the other. You can avoid this (called gimbal lock)
by using quaternions (google for quaternion rotation if you are
interested), but usually just explicitly checking for those cases is
sufficient.
Take care,
Steve
On Dec 16, 2004, at 2:45 PM, Ben Lachman wrote:
I've been banging my head against this for a while now and wondered if
anyone has a solution to this problem.
I have two normals, a and b and I want to find the appropriate
rotation matrix to align them.
Whats the best way of doing this?
TIA,
->Ben
––––––––––––––––––––––––––––––––––––––––
Ben Lachman • email@hidden
email@hidden • 740.594.9192
Apple Campus Representative
Ohio University _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden