19 template <
typename Real>
40 template <
typename Real>
63 template <
typename Real>
88 int numPositive = 0, numNegative = 0, numZero = 0;
89 for (
int i = 0; i < 3; ++i)
91 s[i] =
Dot(plane.normal, triangle.v[i]) - plane.constant;
96 else if (s[i] < (Real)0)
106 if (numZero == 0 && numPositive > 0 && numNegative > 0)
108 result.intersect =
true;
109 result.numIntersections = 2;
110 result.isInterior =
true;
116 result.intersect =
true;
117 for (
int i = 0; i < 3; ++i)
121 if (numPositive == 2 || numNegative == 2)
123 result.numIntersections = 1;
127 result.numIntersections = 2;
128 result.isInterior =
true;
138 result.intersect =
true;
139 result.numIntersections = 2;
140 result.isInterior =
false;
146 result.intersect =
true;
147 result.numIntersections = 3;
151 result.intersect =
false;
152 result.numIntersections = 0;
160 template <
typename Real>
185 int numPositive = 0, numNegative = 0, numZero = 0;
186 for (
int i = 0; i < 3; ++i)
188 s[i] =
Dot(plane.normal, triangle.v[i]) - plane.constant;
193 else if (s[i] < (Real)0)
203 if (numZero == 0 && numPositive > 0 && numNegative > 0)
205 result.intersect =
true;
206 result.numIntersections = 2;
207 result.isInterior =
true;
208 Real sign = (Real)3 - numPositive * (Real)2;
209 for (
int i0 = 0; i0 < 3; ++i0)
211 if (sign * s[i0] >(Real)0)
213 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
214 Real
t1 = s[i1] / (s[i1] - s[i0]);
215 Real t2 = s[i2] / (s[i2] - s[i0]);
216 result.point[0] = triangle.v[i1] + t1 *
217 (triangle.v[i0] - triangle.v[i1]);
218 result.point[1] = triangle.v[i2] + t2 *
219 (triangle.v[i0] - triangle.v[i2]);
228 result.intersect =
true;
229 for (
int i0 = 0; i0 < 3; ++i0)
231 if (s[i0] == (Real)0)
233 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
234 result.point[0] = triangle.v[i0];
235 if (numPositive == 2 || numNegative == 2)
237 result.numIntersections = 1;
241 result.numIntersections = 2;
242 result.isInterior =
true;
243 Real
t = s[i1] / (s[i1] - s[i2]);
244 result.point[1] = triangle.v[i1] + t *
245 (triangle.v[i2] - triangle.v[i1]);
255 result.intersect =
true;
256 result.numIntersections = 2;
257 result.isInterior =
false;
258 for (
int i0 = 0; i0 < 3; ++i0)
260 if (s[i0] != (Real)0)
262 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
263 result.point[0] = triangle.v[i1];
264 result.point[1] = triangle.v[i2];
273 result.intersect =
true;
274 result.numIntersections = 3;
275 result.point[0] = triangle.v[0];
276 result.point[1] = triangle.v[1];
277 result.point[2] = triangle.v[2];
281 result.intersect =
false;
282 result.numIntersections = 0;
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)