本文整理汇总了C++中vec3d::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3d::normalize方法的具体用法?C++ vec3d::normalize怎么用?C++ vec3d::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3d
的用法示例。
在下文中一共展示了vec3d::normalize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: setDirection
void ray::setDirection(const vec3d& direction)
{
_direction = direction.normalize();
}
示例3:
//////////////////
// Constructors //
//////////////////
ray::ray(const vec3d& origin, const vec3d& direction)
{
_origin = origin;
_direction = direction.normalize();
}
示例4: getRotMatrix
//this appears to be for a more mathematical xyz, where z is up
///TODO: rederive this to work with my coordinates
matrix getRotMatrix(vec3d u,double theta){
u.normalize();
const double c=cos(theta);
return I*c+u.crossprodMatrix()*sin(theta)+u.tensorProd(u)*(1-c);
}
示例5:
//////////////////
// Constructors //
//////////////////
directionalLightsource::directionalLightsource(const color& intensity, const vec3d& dir)
{
_intensity = intensity;
_direction = dir.normalize();
}