当前位置: 首页>>代码示例>>C++>>正文


C++ vec3d::normalize方法代码示例

本文整理汇总了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);
  } 
}
开发者ID:behnam,项目名称:cgkit,代码行数:48,代码来源:polyhedrongeom.cpp

示例2: setDirection

void ray::setDirection(const vec3d& direction)
{
  _direction = direction.normalize();
}
开发者ID:Anaisabel95,项目名称:GraphicsClass,代码行数:4,代码来源:ray.cpp

示例3:

//////////////////
// Constructors //
//////////////////
ray::ray(const vec3d& origin, const vec3d& direction)
{
  _origin = origin;
  _direction = direction.normalize();
}
开发者ID:Anaisabel95,项目名称:GraphicsClass,代码行数:8,代码来源:ray.cpp

示例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);
}
开发者ID:gentlecolts,项目名称:engineR2,代码行数:7,代码来源:camera.cpp

示例5:

//////////////////
// Constructors //
//////////////////
directionalLightsource::directionalLightsource(const color& intensity, const vec3d& dir)
{
  _intensity = intensity;
  _direction = dir.normalize();
}
开发者ID:Anaisabel95,项目名称:GraphicsClass,代码行数:8,代码来源:directionalLightsource.cpp


注:本文中的vec3d::normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。