20 template <
typename Real>
33 template <
typename Real>
59 template <
typename Real>
66 Real rSum = sphere0.radius + sphere1.radius;
67 result.intersect = (
Dot(diff, diff) <= rSum*rSum);
71 template <
typename Real>
80 Real sqrLen =
Dot(C1mC0, C1mC0);
81 Real r0 = sphere0.radius, r1 = sphere1.radius;
83 Real rSumSqr = rSum * rSum;
88 result.intersect =
false;
93 if (sqrLen == rSumSqr)
97 result.intersect =
true;
99 result.point = sphere0.center + r0 * C1mC0;
104 Real rDifSqr = rDif*rDif;
105 if (sqrLen < rDifSqr)
109 result.intersect =
true;
110 result.type = (rDif <= (Real)0 ? 3 : 5);
111 result.point = ((Real)0.5)*(sphere0.center + sphere1.center);
114 if (sqrLen == rDifSqr)
119 result.intersect =
true;
123 result.point = sphere1.center + r1 * C1mC0;
128 result.point = sphere0.center + r0 * C1mC0;
135 Real
t = ((Real)0.5) * ((Real)1 + rDif * rSum / sqrLen);
138 result.circle.center = sphere0.center + t * C1mC0;
139 result.circle.radius = sqrt(std::max(r0*r0 - t*t*sqrLen, (Real)0));
143 result.circle.normal = C1mC0;
146 result.intersect =
true;
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Real Normalize(GVector< Real > &v, bool robust=false)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)