问题描述
Vector position;
Vector normal;
float d;
(向量只是辅助类中的 x,y,z)
多年来一直使用它,几乎可以满足我的所有目的。但是,我将它用作学者,并没有真正考虑它的工作原理。
所以...我需要将其转换为 float[4] 格式,供朋友用于某些 OpenGL 渲染。在 float[4] 中将点/法线/d 转换为平面方程的正确方法是什么?我尝试的一切似乎都有点偏离。
[编辑] 这是平面的Create()函数,它给d赋值...
void Create(Vector thePoint,Vector thenormal)
{
thenormal.normalize();
pos=thePoint;
normal=thenormal;
d=-thenormal.Dot(thePoint);
}