17 #ifndef AGXCOLLIDE_POLYGONCLIPPING_H
18 #define AGXCOLLIDE_POLYGONCLIPPING_H
24 #include <agx/agx_vector_types.h>
43 bool clipConvexPolygonAgainstTrianglePrism(
65 if (cPolygon.
size() == 0)
70 for (
size_t i = 0; i < cPolygon.
size(); ++i)
76 planeNormals.
push_back((triangle[1] - triangle[0]) ^ normalTriangle);
77 planeNormals.
push_back((triangle[2] - triangle[1]) ^ normalTriangle);
78 planeNormals.
push_back((triangle[0] - triangle[2]) ^ normalTriangle);
79 planeDist.
push_back(triangle[0] * planeNormals[0]);
80 planeDist.
push_back(triangle[1] * planeNormals[1]);
81 planeDist.
push_back(triangle[2] * planeNormals[2]);
87 for (
unsigned int i = 0; i < 3; ++i) {
89 bool lastPointWasOutside = result[0] * planeNormals[i] - planeDist[i] > epsilon;
91 for (
size_t j = 0; j < result.
size(); ++j) {
92 size_t j_next = (j + 1) % result.
size();
93 bool nextPointIsOutside = result[j_next] * planeNormals[i] - planeDist[i] > epsilon;
94 if (lastPointWasOutside != nextPointIsOutside) {
98 if (intersectLineSegmentHyperPlane( result[j], result[j_next], planeNormals[i], planeDist[i], tmpT, newPoint, epsilon ))
101 if (!nextPointIsOutside)
103 lastPointWasOutside = nextPointIsOutside;
110 for (
size_t j = 0; j < tmp.
size(); ++j) {
111 if (result.
size() == 0 ||
112 ((result.
back() - tmp[j]).length2() > epsilon && (result.
front() - tmp[j]).length2() > epsilon))
Templated stack array class.
size_t size() const
Get the size of the array (number of filled slots).
void push_back(const T &value)
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
This namespace consists of a set of classes for handling geometric intersection tests including boole...