gpt4 book ai didi

时间:2018-03-08 标签:c++opengl: how to find normalized vectors for a quad?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:03:20 25 4
gpt4 key购买 nike

谁能帮我找到正确的四元归一化公式?

将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com