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


C++ vec3_t::normalise方法代码示例

本文整理汇总了C++中vec3_t::normalise方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3_t::normalise方法的具体用法?C++ vec3_t::normalise怎么用?C++ vec3_t::normalise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vec3_t的用法示例。


在下文中一共展示了vec3_t::normalise方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shootRay

BrlCadInterface::HitType BrlCadInterface::shootRay(vec3_t x, vec3_t v, vec3_t &x_hit, vec3_t &n_hit, double &r)
{
  HitType hit_type = Miss;
  v.normalise();
  vec3_t x_in, x_out, n_in, n_out;
  double r_in, r_out;
  if (brlCadShootRay(x, v, x_in, x_out, n_in, n_out, r_in, r_out)) {
    double d_in = (x_in - x)*v;
    if (d_in > 0) {
      x_hit = x_in;
      n_hit = n_in;
      r = r_in;
      hit_type = HitIn;
    }
    double d_out = (x_out - x)*v;
    if (d_out > 0) {
      if (hit_type == Miss || d_out < d_in) {
        x_hit = x_out;
        n_hit = n_out;
        hit_type = HitOut;
        r = r_out;
      }
    }
  }
  return hit_type;
}
开发者ID:Nasrollah,项目名称:engrid,代码行数:26,代码来源:brlcadinterface.cpp

示例2: rotate

vec3_t rotate(vec3_t v, vec3_t axis, double theta)
{
  axis.normalise();
  
  // transposed base of rotate system
  mat3_t g_t;

  // compute projection of v in axis direction
  vec3_t v_axis = (axis*v)*axis;

  // compute first orthogonal vector (first base vector)
  g_t[0] = v-v_axis;
  
  //In case of points on the rotation axis, do nothing
  if(g_t[0].abs()==0) return v;
  
  g_t[0].normalise();

  // second base vector is the normalised axis
  g_t[1] = axis;

  // compute second orthogonal vector (third base vector)
  g_t[2] = g_t[0].cross(g_t[1]);

  // base of rotate system
  mat3_t g = g_t.transp();

  // matrix for rotation around g_t[1];
  mat3_t rot = mat3_t::identity();
  rot[0][0] =  cos(theta);
  rot[0][2] =  sin(theta);
  rot[2][0] = -sin(theta);
  rot[2][2] =  cos(theta);

  // transfer v to rotate system
  vec3_t v_r = g_t*v;

  // rotate the vector and transfer it back
  v_r = rot*v_r;
  v = g*v_r;

  return v;
}
开发者ID:Haider-BA,项目名称:engrid,代码行数:43,代码来源:geometrytools.cpp

示例3: shootRay

bool CreateCadTesselation::shootRay(vec3_t x, vec3_t v, vec3_t &x_in, vec3_t &x_out, vec3_t &n_in, vec3_t &n_out)
{
  v.normalise();
  double r_hit;
  vec3_t x_hit, n_hit;
  CadInterface::HitType hit_type = m_CadInterface->shootRay(x, v, x_hit, n_hit, r_hit);
  if (hit_type == CadInterface::Miss || hit_type == CadInterface::HitOut) {
    return false;
  }
  x_in = x_hit;
  n_in = n_hit;
  x = x_in;
  do {
    x += 1e-10*v;
    hit_type = m_CadInterface->shootRay(x, v, x_hit, n_hit, r_hit);
    if (hit_type == CadInterface::HitOut) {
      x_out = x_hit;
      n_out = n_hit;
    }
    x = x_hit;
  } while (hit_type == CadInterface::HitIn);
  return true;
}
开发者ID:enGits,项目名称:engrid,代码行数:23,代码来源:createcadtesselation.cpp

示例4: intersectionOnPlane

vec3_t intersectionOnPlane(vec3_t v, vec3_t A, vec3_t nA, vec3_t B, vec3_t nB)
{
  vec3_t u = B-A;
//   u.normalise();
  v.normalise();
  v = u.abs()*v;
  
  //cout<<"u="<<u<<" v="<<v<<endl;
  
  vec2_t p_A(0,0);
  vec2_t p_B(1,0);
  vec2_t p_nA = projectVectorOnPlane(nA,u,v);
  vec2_t p_nB = projectVectorOnPlane(nB,u,v);
  
  vec2_t p_tA = turnRight(p_nA);
  vec2_t p_tB = turnRight(p_nB);
  
  double k1, k2;
  vec2_t p_K;
  if(!intersection(k1, k2, p_A, p_tA, p_B, p_tB)) {
    //qDebug()<<"WARNING: No intersection found!!!";
    p_K = 0.5*(p_A + p_B);
  }
  else {
    p_K = p_A + k1*p_tA;
  }
  
  //cout<<"nA="<<nA<<endl;
  //cout<<"p_nA="<<p_nA<<endl;
  //cout<<"p_tA="<<p_tA<<endl;
  //cout<<"p_K="<<p_K<<endl;
  if(p_K[0]<0) p_K[0] = 0;
  if(p_K[0]>1) p_K[0] = 1;
  vec3_t K = A + p_K[0]*u + p_K[1]*v;
  //cout<<"K="<<K<<endl;
  return K;
}
开发者ID:Haider-BA,项目名称:engrid,代码行数:37,代码来源:geometrytools.cpp

示例5: foreach

 foreach (vec3_t nf, m_Faces) {
   nf.normalise();
   double h = nf*n0;
   hf = min(h, hf);
 }
开发者ID:danbarrynz,项目名称:engrid,代码行数:5,代码来源:optimisenormalvector.cpp


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