22 template <
typename Real>
35 template <
typename Real>
55 template <
typename Real>
65 for (
int i = 0; i < 3; ++i)
67 s[i] =
Dot(halfspace.normal, triangle.v[i]) - halfspace.constant;
72 result.intersect = (std::max(std::max(s[0], s[1]), s[2]) >= (Real)0);
76 template <
typename Real>
101 int numPositive = 0, numNegative = 0, numZero = 0;
102 for (
int i = 0; i < 3; ++i)
104 s[i] =
Dot(halfspace.normal, triangle.v[i]) - halfspace.constant;
109 else if (s[i] < (Real)0)
119 if (numNegative == 0)
122 result.intersect =
true;
123 result.numPoints = 3;
124 result.point[0] = triangle.v[0];
125 result.point[1] = triangle.v[1];
126 result.point[2] = triangle.v[2];
128 else if (numNegative == 1)
130 result.intersect =
true;
131 if (numPositive == 2)
135 result.numPoints = 4;
136 for (
int i0 = 0; i0 < 3; ++i0)
140 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
141 result.point[0] = triangle.v[i1];
142 result.point[1] = triangle.v[i2];
143 Real t2 = s[i2] / (s[i2] - s[i0]);
144 Real
t0 = s[i0] / (s[i0] - s[i1]);
145 result.point[2] = triangle.v[i2] + t2 *
146 (triangle.v[i0] - triangle.v[i2]);
147 result.point[3] = triangle.v[i0] + t0 *
148 (triangle.v[i1] - triangle.v[i0]);
153 else if (numPositive == 1)
157 result.numPoints = 3;
158 for (
int i0 = 0; i0 < 3; ++i0)
160 if (s[i0] == (Real)0)
162 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
163 result.point[0] = triangle.v[i0];
164 Real
t1 = s[i1] / (s[i1] - s[i2]);
166 (triangle.v[i2] - triangle.v[i1]);
169 result.point[1] = triangle.v[i1];
175 result.point[2] = triangle.v[i2];
184 result.numPoints = 0;
185 for (
int i = 0; i < 3; ++i)
189 result.point[result.numPoints++] = triangle.v[i];
194 else if (numNegative == 2)
196 result.intersect =
true;
197 if (numPositive == 1)
200 result.numPoints = 3;
201 for (
int i0 = 0; i0 < 3; ++i0)
205 int i1 = (i0 + 1) % 3, i2 = (i0 + 2) % 3;
206 result.point[0] = triangle.v[i0];
207 Real
t0 = s[i0] / (s[i0] - s[i1]);
208 Real t2 = s[i2] / (s[i2] - s[i0]);
209 result.point[1] = triangle.v[i0] + t0 *
210 (triangle.v[i1] - triangle.v[i0]);
211 result.point[2] = triangle.v[i2] + t2 *
212 (triangle.v[i0] - triangle.v[i2]);
220 result.numPoints = 1;
221 for (
int i = 0; i < 3; ++i)
225 result.point[0] = triangle.v[i];
234 result.intersect =
false;
235 result.numPoints = 0;
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
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)