Package toxi.geom.mesh2d

Examples of toxi.geom.mesh2d.Voronoi


    public List<Triangle2D> tesselatePolygon(Polygon2D poly) {
        List<Triangle2D> triangles = new ArrayList<Triangle2D>();
        Rect bounds = poly.getBounds();
        // a Voronoi diagram relies on a Delaunay triangulation behind the
        // scenes
        Voronoi voronoi = new Voronoi(rootSize);
        // add perimeter points
        for (Vec2D v : poly.vertices) {
            voronoi.addPoint(v);
        }
        // add random inliers
        for (Vec2D v : createInsidePoints(poly, bounds)) {
            voronoi.addPoint(v);
        }
        // get filtered delaunay triangles:
        // ignore any triangles which share a vertex with the initial root
        // triangle or whose centroid is outside the polygon
        for (Triangle2D t : voronoi.getTriangles()) {
            if (MathUtils.abs(t.a.x) != Voronoi.DEFAULT_SIZE
                    && MathUtils.abs(t.a.y) != Voronoi.DEFAULT_SIZE) {
                if (poly.containsPoint(t.computeCentroid())) {
                    triangles.add(t);
                }
View Full Code Here

TOP

Related Classes of toxi.geom.mesh2d.Voronoi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.