19 template <
typename Real>
32 Real& imin, Real& imax);
35 Real& imin, Real& imax);
38 template <
typename Real>
52 template <
typename Real>
60 Real min0, max0, min1, max1;
64 edge[0] = triangle.v[1] - triangle.v[0];
65 edge[1] = triangle.v[2] - triangle.v[0];
66 D =
Cross(edge[0], edge[1]);
67 min0 =
Dot(D, triangle.v[0]);
69 GetProjection(D, box, min1, max1);
70 if (max1 < min0 || max0 < min1)
72 result.intersect =
false;
77 for (
int i = 0; i < 3; ++i)
80 GetProjection(D, triangle, min0, max0);
81 Real DdC =
Dot(D, box.center);
82 min1 = DdC - box.extent[i];
83 max1 = DdC + box.extent[i];
84 if (max1 < min0 || max0 < min1)
86 result.intersect =
false;
92 edge[2] = edge[1] - edge[0];
93 for (
int i0 = 0; i0 < 3; ++i0)
95 for (
int i1 = 0; i1 < 3; ++i1)
97 D =
Cross(edge[i0], box.axis[i1]);
98 GetProjection(D, triangle, min0, max0);
99 GetProjection(D, box, min1, max1);
100 if (max1 < min0 || max0 < min1)
102 result.intersect =
false;
108 result.intersect =
true;
112 template <
typename Real>
118 Dot(axis, triangle.
v[0]),
119 Dot(axis, triangle.
v[1]),
120 Dot(axis, triangle.
v[2])
130 else if (dot[1] > imax)
139 else if (dot[2] > imax)
145 template <
typename Real>
155 imin = origin - maximumExtent;
156 imax = origin + maximumExtent;
159 template <
typename Real>
168 result.insidePolygon.resize(3);
169 for (
int i = 0; i < 3; ++i)
171 result.insidePolygon[i] = triangle.v[i];
177 for (
int dir = -1; dir <= 1; dir += 2)
179 for (
int side = 0; side < 3; ++side)
182 plane.
normal = ((Real)dir) * box.axis[side];
185 ppResult = ppQuery(result.insidePolygon, plane);
186 switch (ppResult.configuration)
189 result.insidePolygon = ppResult.positivePolygon;
190 result.outsidePolygons.push_back(ppResult.negativePolygon);
201 result.insidePolygon.clear();
202 result.outsidePolygons.push_back(ppResult.negativePolygon);
207 result.insidePolygon = ppResult.intersection;
210 result.insidePolygon.clear();
211 result.outsidePolygons.clear();
std::array< Vector< N, Real >, N > axis
std::vector< Vector3< Real > > insidePolygon
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
std::vector< std::vector< Vector3< Real > > > outsidePolygons
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)
std::array< Vector< N, Real >, 3 > v