21 template <
typename Real>
34 template <
typename Real>
43 std::array<Vector2<Real>, 2>
point;
56 template <
typename Real>
81 int numPositive = 0, numNegative = 0, numZero = 0;
82 for (
int i = 0; i < 3; ++i)
85 s[i] =
DotPerp(line.direction, diff);
90 else if (s[i] < (Real)0)
101 (numZero == 0 && (numPositive == 0 || numNegative == 0)) ||
107 template <
typename Real>
113 DoQuery(line.origin, line.direction, triangle, result);
114 for (
int i = 0; i < result.numIntersections; ++i)
116 result.point[i] = line.origin + result.parameter[i] * line.direction;
121 template <
typename Real>
144 int numPositive = 0, numNegative = 0, numZero = 0;
145 for (
int i = 0; i < 3; ++i)
148 s[i] =
DotPerp(lineDirection, diff);
153 else if (s[i] < (Real)0)
163 if (numZero == 0 && numPositive > 0 && numNegative > 0)
165 result.intersect =
true;
166 result.numIntersections = 2;
167 Real sign = (Real)3 - numPositive * (Real)2;
168 for (
int i0 = 0; i0 < 3; ++i0)
170 if (sign * s[i0] >(Real)0)
172 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
173 Real
s1 = s[i1] / (s[i1] - s[i0]);
175 s1 * (triangle.
v[i0] - triangle.
v[i1]);
176 result.parameter[0] =
Dot(lineDirection, p1);
177 Real s2 = s[i2] / (s[i2] - s[i0]);
179 s2 * (triangle.
v[i0] - triangle.
v[i2]);
180 result.parameter[1] =
Dot(lineDirection, p2);
189 result.intersect =
true;
190 for (
int i0 = 0; i0 < 3; ++i0)
192 if (s[i0] == (Real)0)
194 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
195 result.parameter[0] =
196 Dot(lineDirection, triangle.
v[i0] - lineOrigin);
197 if (numPositive == 2 || numNegative == 2)
199 result.numIntersections = 1;
202 result.parameter[1] = result.parameter[0];
206 result.numIntersections = 2;
207 Real
s1 = s[i1] / (s[i1] - s[i2]);
209 s1 * (triangle.
v[i2] - triangle.
v[i1]);
210 result.parameter[1] =
Dot(lineDirection, p1);
220 result.intersect =
true;
221 result.numIntersections = 2;
222 for (
int i0 = 0; i0 < 3; ++i0)
224 if (s[i0] != (Real)0)
226 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
227 result.parameter[0] =
228 Dot(lineDirection, triangle.
v[i1] - lineOrigin);
229 result.parameter[1] =
230 Dot(lineDirection, triangle.
v[i2] - lineOrigin);
238 result.intersect =
false;
239 result.numIntersections = 0;
std::array< Vector2< Real >, 2 > point
Real DotPerp(Vector2< Real > const &v0, Vector2< Real > const &v1)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
std::array< Real, 2 > parameter
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
std::array< Vector< N, Real >, 3 > v