简体   繁体   中英

rotation using plane normal

I have a plane in the origin.

glBegin(GL_POLYGON);
glVertex3f(-10.0, -10.0,0.0);
glVertex3f(10.0, -10.0, 0.0);
glVertex3f(10.0, 10.0,  0.0);
glVertex3f(-10.0, 10.0, 0.0);
glEnd();

Than I am trying to rotate this plane for a new normal 1 0 0.

I understand that To calculate the angle between the two normals, I need to find the old normal. How can I find the old normal? and when I find the old normal do I have to enter in the new normal to rotate, like glRotatef(angle,1,0,0) ?

All of your vertices lie within the XY plane and therefore your normal is simply in the Z direction (0,0,1) or (0,0,-1). If you want to rotate you polygon to point its normal in the X direction you will need to rotate it 90 degrees about the Y axis, glRotatef(90.0f,0,1,0) or glRotatef(-90.0f,0,1,0).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM