# Rotating a polygon into y=0 plane

I need to rotate a polygon from it’s current position into the y=0 plane. How do I do that? I currently calculate a matrix using the new basis and transform the vertices.

Apperantly, this method have some faults.

What orientation should the polygon have in the y=0 plane? If you don’t care, then any transformation which rotates the polygon’s normal to the plane normal ([0,1,0] or [0,-1,0]) will do. The one typically used would be a rotation about an axis normal to both the polygon normal and plane normal (watch out for the cases where the angle between the normals is very near 180 degrees though.)

However, think carefully about whether there is for a given polygon some natural orientation in the y=0 plane that would allow you to completely specify the transformation.

–Chris

I need the transformation for UV coordinates calculations. So I guess I need to save the natural orientation.

Now, I create a basis of three vectors:

• The polygon’s normal
• The X axis
• Thier Cross Product

I use the basis matris to transfotm the polygon. It works fine, but sometime it seems to malfunction.

Do I do it right?

Take the cross product of the poly normal (the cross product of two of it’s edges) and the y axis to give a rotation vector, and rotate about that vector by the acos of the dot product of the same normal and axis.