本文整理汇总了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;
}