19 template <
typename Real>
31 template <
typename Real>
50 template <
typename Real>
57 Real invSin = ((Real)1) / cone.sinAngle;
58 Real cosSqr = cone.cosAngle * cone.cosAngle;
60 Vector3<Real> D = CmV + (sphere.radius * invSin) * cone.ray.direction;
61 Real lenSqr =
Dot(D, D);
62 Real e =
Dot(D, cone.ray.direction);
63 if (e > (Real)0 && e*e >= lenSqr*cosSqr)
65 Real sinSqr = cone.sinAngle * cone.sinAngle;
66 lenSqr =
Dot(CmV, CmV);
67 e = -
Dot(CmV, cone.ray.direction);
68 if (e > (Real)0 && e*e >= lenSqr*sinSqr)
70 Real rSqr = sphere.radius * sphere.radius;
71 result.intersect = (lenSqr <= rSqr);
75 result.intersect =
true;
80 result.intersect =
false;
86 template <
typename Real>
95 Real rSqr = sphere.radius * sphere.radius;
96 Real lenSqr =
Dot(diff, diff);
101 result.intersect =
true;
102 result.point = cone.ray.origin;
107 Real dot =
Dot(diff, cone.ray.direction);
108 Real dotSqr = dot*dot;
109 Real cosSqr = cone.cosAngle * cone.cosAngle;
110 if (dotSqr >= lenSqr*cosSqr && dot > (Real)0)
114 result.intersect =
true;
115 result.point = sphere.center;
136 Real uLen = sqrt(std::max(lenSqr - dotSqr, (Real)0));
137 Real test = cone.cosAngle * dot + cone.sinAngle * uLen;
138 Real discr = test * test - lenSqr + rSqr;
140 if (discr >= (Real)0 && test >= (Real)0)
143 result.intersect =
true;
144 Real
t = test - sqrt(std::max(discr, (Real)0));
146 Real tmp = cone.sinAngle / uLen;
147 result.point = t * (cone.cosAngle * cone.ray.direction + tmp * B);
151 result.intersect =
false;
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)