static unsigned findNextEdgeVertexIndex(const FloatPolygon& polygon, unsigned vertexIndex1, bool clockwise) { unsigned nVertices = polygon.numberOfVertices(); unsigned vertexIndex2 = nextVertexIndex(vertexIndex1, nVertices, clockwise); while (vertexIndex2 && areCoincidentPoints(polygon.vertexAt(vertexIndex1), polygon.vertexAt(vertexIndex2))) vertexIndex2 = nextVertexIndex(vertexIndex2, nVertices, clockwise); while (vertexIndex2) { unsigned vertexIndex3 = nextVertexIndex(vertexIndex2, nVertices, clockwise); if (!areCollinearPoints(polygon.vertexAt(vertexIndex1), polygon.vertexAt(vertexIndex2), polygon.vertexAt(vertexIndex3))) break; vertexIndex2 = vertexIndex3; } return vertexIndex2; }
unsigned ExclusionPolygon::findNextEdgeVertexIndex(unsigned vertexIndex1, bool clockwise) const { unsigned nVertices = numberOfVertices(); unsigned vertexIndex2 = nextVertexIndex(vertexIndex1, nVertices, clockwise); while (vertexIndex2 && areCoincidentPoints(vertexAt(vertexIndex1), vertexAt(vertexIndex2))) vertexIndex2 = nextVertexIndex(vertexIndex2, nVertices, clockwise); while (vertexIndex2) { unsigned vertexIndex3 = nextVertexIndex(vertexIndex2, nVertices, clockwise); if (!areCollinearPoints(vertexAt(vertexIndex1), vertexAt(vertexIndex2), vertexAt(vertexIndex3))) break; vertexIndex2 = vertexIndex3; } return vertexIndex2; }
static inline bool isPointOnLineSegment(const FloatPoint& vertex1, const FloatPoint& vertex2, const FloatPoint& point) { return point.x() >= std::min(vertex1.x(), vertex2.x()) && point.x() <= std::max(vertex1.x(), vertex2.x()) && areCollinearPoints(vertex1, vertex2, point); }