作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
谁能帮我找到正确的四元归一化公式?
将 c++ 与 opengl 结合使用。
谢谢!
最佳答案
Newell 方法通常是计算接近平面的多边形法线的最佳选择。它往往对轻微的违规行为相当稳健,而不会太昂贵。查看Graphics Gems article .它类似于上面描述的:
Vector3d normal(0,0,0) ;
for (int i=0; i<4; i++)
{
int j = (i+1)%4;
normal.x += (vertex[i].y - vertex[j].y)
*(vertex[i].z + vertex[j].z);
normal.y += (vertex[i].z - vertex[j].z)
*(vertex[i].x + vertex[j].x);
normal.z += (vertex[i].x - vertex[j].x)
*(vertex[i].y + vertex[j].y);
}
normalize (normal) ;
如果四边形表现得相当好,它可能不会有太大影响,但如果您要处理更复杂的多边形,我肯定会使用它。
关于时间:2018-03-08 标签:c++opengl: how to find normalized vectors for a quad?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2582367/
我是一名优秀的程序员,十分优秀!