简体   繁体   English

使用平面法线旋转

[英]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. 比我尝试将平面旋转一个新的法线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) ? 当我找到旧的法线时,是否必须输入新的法线进行旋转,例如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). 您所有的顶点都在XY平面内,因此您的法线只是在Z方向上(0,0,1)或(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). 如果要旋转多边形以使其法线指向X方向,则需要将其绕Y轴旋转90度,glRotatef(90.0f,0,1,0)或glRotatef(-90.0f,0,1, 0)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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