/** Brute force compute if a point is in the polygon by traversing entire triangulation * todo: speed this up using either binary tree or prefix coding (filtering by bounding box of triangle) **/ public static final boolean pointInPolygon(final List<Triangle> tessellation, double lat, double lon) { // each triangle for (int i = 0; i < tessellation.size(); ++i) { if (tessellation.get(i).containsPoint(lat, lon)) { return true; } } return false; }
if (isReflex == false && isEar(currEar, mortonOptimized) == true) { tessellation.add(new Triangle(prevNode, currEar, nextNode));
/** Iterate through all polygon nodes and remove small local self-intersections **/ private static final Node cureLocalIntersections(Node startNode, final List<Triangle> tessellation) { Node node = startNode; Node nextNode; do { nextNode = node.next; Node a = node.previous; Node b = nextNode.next; // a self-intersection where edge (v[i-1],v[i]) intersects (v[i+1],v[i+2]) if (isVertexEquals(a, b) == false && isIntersectingPolygon(a, a.getX(), a.getY(), b.getX(), b.getY()) == false && linesIntersect(a.getX(), a.getY(), node.getX(), node.getY(), nextNode.getX(), nextNode.getY(), b.getX(), b.getY()) && isLocallyInside(a, b) && isLocallyInside(b, a)) { // Return the triangulated vertices to the tessellation tessellation.add(new Triangle(a, node, b)); // remove two nodes involved removeNode(node); removeNode(node.next); node = startNode = b; } node = node.next; } while (node != startNode); return node; }
LatLonTriangle(String name, Triangle t) { super(name, TYPE); setTriangleValue(t.getEncodedX(0), t.getEncodedY(0), t.getEncodedX(1), t.getEncodedY(1), t.getEncodedX(2), t.getEncodedY(2)); }