19 template <
typename Real>
31 template <
typename Real>
40 std::array<Vector3<Real>, 2>
point;
52 template <
typename Real>
64 Real a0 =
Dot(diff, diff) - sphere.radius * sphere.radius;
65 Real a1 =
Dot(line.direction, diff);
68 Real discr = a1*a1 - a0;
69 result.intersect = (discr >= (Real)0);
73 template <
typename Real>
79 DoQuery(line.origin, line.direction, sphere, result);
80 for (
int i = 0; i < result.numIntersections; ++i)
82 result.point[i] = line.origin + result.parameter[i] * line.direction;
87 template <
typename Real>
98 Real a1 =
Dot(lineDirection, diff);
101 Real discr = a1*a1 - a0;
104 result.intersect =
true;
105 result.numIntersections = 2;
106 Real root = sqrt(discr);
107 result.parameter[0] = -a1 - root;
108 result.parameter[1] = -a1 + root;
110 else if (discr < (Real)0)
112 result.intersect =
false;
113 result.numIntersections = 0;
117 result.intersect =
true;
118 result.numIntersections = 1;
119 result.parameter[0] = -a1;
std::array< Real, 2 > parameter
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
std::array< Vector3< Real >, 2 > point
Result operator()(Type0 const &primitive0, Type1 const &primitive1)