17 template <
typename Real>
30 template <
typename Real>
33 public FIQuery<Real, Line3<Real>, Sphere3<Real>>
38 public FIQuery<Real, Line3<Real>, Sphere3<Real>>::Result
53 template <
typename Real>
66 segment.GetCenteredForm(segOrigin, segDirection, segExtent);
69 Real a0 =
Dot(diff, diff) - sphere.radius * sphere.radius;
70 Real a1 =
Dot(segDirection, diff);
71 Real discr = a1*a1 - a0;
74 result.intersect =
false;
78 Real tmp0 = segExtent*segExtent + a0;
79 Real tmp1 = ((Real)2)*a1*segExtent;
80 Real qm = tmp0 - tmp1;
81 Real qp = tmp0 + tmp1;
84 result.intersect =
true;
88 result.intersect = (qm > (Real)0 &&
std::abs(a1) < segExtent);
92 template <
typename Real>
99 segment.GetCenteredForm(segOrigin, segDirection, segExtent);
102 DoQuery(segOrigin, segDirection, segExtent, sphere, result);
103 for (
int i = 0; i < result.numIntersections; ++i)
105 result.point[i] = segOrigin + result.parameter[i] * segDirection;
110 template <
typename Real>
116 segDirection, sphere, result);
118 if (result.intersect)
124 std::array<Real, 2> segInterval = { -segExtent, segExtent };
126 auto iiResult = iiQuery(result.parameter, segInterval);
127 if (iiResult.intersect)
129 result.numIntersections = iiResult.numIntersections;
130 result.parameter = iiResult.overlap;
134 result.intersect =
false;
135 result.numIntersections = 0;
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)