本文整理汇总了C++中vec3d::cross方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3d::cross方法的具体用法?C++ vec3d::cross怎么用?C++ vec3d::cross使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3d
的用法示例。
在下文中一共展示了vec3d::cross方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeNormal
/**
Compute the normal for a polygon.
Basically, the method simply takes the first three vertices A, B, C and
computes the normal of that triangle.
However, it is checked that A!=B and B!=C, so it is possible that more than
three vertices are looked up.
\param poly Polygon index
\param[out] N Receives the resulting normal
*/
void PolyhedronGeom::computeNormal(int poly, vec3d& N)
{
VertexLoop& loop = *(*polys[poly])[0];
int size = loop.size();
int i = 2;
if (size<3)
return;
const vec3d* a = &(verts.getValue(loop[0]));
const vec3d* b = &(verts.getValue(loop[1]));
while(a==b)
{
if (i>=size)
return;
b = &(verts.getValue(loop[i]));
i++;
}
const vec3d* c = &(verts.getValue(loop[i]));
while(b==c)
{
if (i>=size)
return;
c = &(verts.getValue(loop[i]));
i++;
}
N.cross((*b)-(*a), (*c)-(*a));
try
{
N.normalize(N);
}
catch(...)
{
N.set(0,0,0);
}
}