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


C++ PlainObjectBase::dot方法代码示例

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


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

示例1: ray_sphere_intersect

IGL_INLINE int igl::ray_sphere_intersect(
  const Eigen::PlainObjectBase<Derivedo> & ao,
  const Eigen::PlainObjectBase<Derivedd> & d,
  const Eigen::PlainObjectBase<Derivedc> & ac,
  r_type r, 
  t_type & t0,
  t_type & t1)
{
  Eigen::Vector3d o = ao-ac;
  // http://wiki.cgsociety.org/index.php/Ray_Sphere_Intersection
  //Compute A, B and C coefficients
  double a = d.dot(d);
  double b = 2 * d.dot(o);
  double c = o.dot(o) - (r * r);

  //Find discriminant
  double disc = b * b - 4 * a * c;
    
  // if discriminant is negative there are no real roots, so return 
  // false as ray misses sphere
  if (disc < 0)
  {
    return 0;
  }

  // compute q as described above
  double distSqrt = sqrt(disc);
  double q;
  if (b < 0)
  {
    q = (-b - distSqrt)/2.0;
  } else
  {
    q = (-b + distSqrt)/2.0;
  }

  // compute t0 and t1
  t0 = q / a;
  double _t1 = c/q;
  if(_t1 == t0)
  {
    return 1;
  }
  t1 = _t1;
  // make sure t0 is smaller than t1
  if (t0 > t1)
  {
    // if t0 is bigger than t1 swap them around
    double temp = t0;
    t0 = t1;
    t1 = temp;
  }
  return 2;
}
开发者ID:kevinsunsh,项目名称:libigl,代码行数:54,代码来源:ray_sphere_intersect.cpp


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