19 template <
typename Real>
32 template <
typename Real>
59 template <
typename Real>
66 result.intersect = (
Length(diff) <= circle0.radius + circle1.radius);
70 template <
typename Real>
100 Real USqrLen =
Dot(U, U);
101 Real R0 = circle0.radius, R1 = circle1.radius;
102 Real R0mR1 = R0 - R1;
103 if (USqrLen == (Real)0 && R0mR1 == (Real)0)
106 result.intersect =
true;
107 result.numIntersections = std::numeric_limits<int>::max();
108 result.circle = circle0;
112 Real R0mR1Sqr = R0mR1*R0mR1;
113 if (USqrLen < R0mR1Sqr)
116 result.intersect =
false;
117 result.numIntersections = 0;
121 Real R0pR1 = R0 + R1;
122 Real R0pR1Sqr = R0pR1*R0pR1;
123 if (USqrLen > R0pR1Sqr)
126 result.intersect =
false;
127 result.numIntersections = 0;
131 if (USqrLen < R0pR1Sqr)
133 if (R0mR1Sqr < USqrLen)
135 Real invUSqrLen = ((Real)1) / USqrLen;
136 Real
s = ((Real)0.5)*((R0*R0 - R1*R1)*invUSqrLen + (Real)1);
141 Real discr = R0*R0*invUSqrLen - s*
s;
146 Real
t = sqrt(discr);
148 result.point[0] = tmp - t*V;
149 result.point[1] = tmp + t*V;
150 result.numIntersections = (t >(Real)0 ? 2 : 1);
155 result.numIntersections = 1;
156 result.point[0] = circle0.center + (R0 / R0mR1)*U;
162 result.numIntersections = 1;
163 result.point[0] = circle0.center + (R0 / R0pR1)*U;
167 result.intersect =
true;
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > Length(DualQuaternion< Real > const &d, bool robust=false)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)