public static List<Point2d> process(List<Point2d> contour) { List<Point2d> result = new ArrayList<Point2d>(); process(contour, result); return result; }
public static List<Point2d> removeClosePoints(List<Point2d> points) { // XXX change to point2d ! return removeClosePoints(points, EPSILON); }
if (0.0f < area(contour)) { for (int v = 0; v < n; v++) { V[v] = v; logBadPolygon(contour); return false; if (snip(contour, u, v, w, nv, V)) { int a, b, c, s, t;
public static void main(String[] args) { Triangulate t = new Triangulate(); List<Point2d> pContour = new ArrayList<Point2d>(); pContour.add(new Point2d(1.895497121847469, -43.471537857796115)); pContour.add(new Point2d(-0.9242217038848146, -42.12385244107362)); pContour.add(new Point2d(-3.743943196278786, -40.77616574981941)); pContour.add(new Point2d(2.2851311803030017, -28.168042068609704)); List<Integer> processIndex = t.processIndex(pContour); }
Triangulate t = new Triangulate(); poly = t.removeClosePoints1(poly); List<Integer> trianglePoly = t.processIndex(poly);
private List<Point2d> calsHookPoints(List<Point2d> points, Integer numOfTrees) { double area = Math.abs(Triangulate.area(points)); if (numOfTrees == null) { // 1 tree on 100 square meters numOfTrees = (int) Math.round(area / 100d); } if (numOfTrees > 1000) { // XXX numOfTrees = 1000; } PolygonList2d polygon = new PolygonList2d(points); return monteCarloHookGenerator(polygon, numOfTrees); }
static boolean snip(List<Point2d> contour, int u, int v, int w, int n,/* ??? */ int[] V) { int p; double Ax, Ay, Bx, By, Cx, Cy, Px, Py; Ax = contour.get(V[u]).x; Ay = contour.get(V[u]).y; Bx = contour.get(V[v]).x; By = contour.get(V[v]).y; Cx = contour.get(V[w]).x; Cy = contour.get(V[w]).y; if (EPSILON > (Bx - Ax) * (Cy - Ay) - (By - Ay) * (Cx - Ax)) { return false; } for (p = 0; p < n; p++) { if (p == u || p == v || p == w) { continue; } Px = contour.get(V[p]).x; Py = contour.get(V[p]).y; if (insideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py)) { return false; } } return true; }
if (0.0f < area(contour)) { for (int v = 0; v < n; v++) { V[v] = v; logBadPolygon(contour); return null; if (snip(contour, u, v, w, nv, V)) { int a, b, c, s, t;
@Deprecated private static List<Integer> trianglePolytriangulateSweeped(List<Point2d> poly) { // FIXME remove this method and switch to PolygonUtil int size = poly.size(); List<Point2d> polySweeped = new ArrayList<Point2d>(); for (Point2d point2d : poly) { polySweeped.add(new Point2d(point2d.x + 0.3 + Double.MIN_VALUE, point2d.y + 0.3 + Double.MIN_VALUE)); } // sweep polySweeped.add(polySweeped.remove(0)); Triangulate t = new Triangulate(); List<Integer> trianglePoly = t.processIndex(poly); if (trianglePoly == null) { return null; } List<Integer> ret = new ArrayList<Integer>(); for (Integer integer : trianglePoly) { // sweep back ret.add((integer + 1) % size); } return ret; } }
private static boolean isWallCounterClockwise(Wall wall) { PolygonList2d wallToPolygon = BuildingUtil.wallToOuterPolygon(wall); if (0.0f < Triangulate.area(wallToPolygon.getPoints())) { return true; } return false; }
public List<Point2d> removeClosePoints1(List<Point2d> pPoints) { return removeClosePoints(pPoints, EPSILON); }