Sha256: 26a4cdc3deee9ea60bd74f82a0eae57532aab8f2404d283033c7a2c90aa6307d
Contents?: true
Size: 1.71 KB
Versions: 11
Compression:
Stored size: 1.71 KB
Contents
package toxi.geom; import java.util.ArrayList; import java.util.List; import toxi.math.MathUtils; /** * A concrete implementation of the abstract {@link GridTesselator} using a grid * in global coordinate space for generating additional points within a polygon. * The resolution setting of this class defines the axis-aligned distance * between grid points. E.g. a resolution of 10 means grid points are created a * world space positions of multiples of 10 (i.e. 0,10,20 etc.). This resolution * is used independently on polygon size, so depending on the chosen resolution * and polygon size no additional inliers MIGHT be created at all. This behavior * property is useful in cases where you want to adjust the number of resulting * triangles dynamically, e.g. based on polygon size. Use the * {@link LocalGridTesselator} for an alternative behavior. * * @see GridTesselator * @see LocalGridTesselator * @see PolygonTesselator */ public class GlobalGridTesselator extends GridTesselator { /** * * @param res */ public GlobalGridTesselator(float res) { super(res); } /** * * @param poly * @param bounds * @return */ @Override protected List<Vec2D> createInsidePoints(Polygon2D poly, Rect bounds) { List<Vec2D> points = new ArrayList<>(); for (float y = bounds.y; y < bounds.getBottom(); y += res) { float yy = MathUtils.roundTo(y, res); for (float x = bounds.x; x < bounds.getRight(); x += res) { Vec2D p = new Vec2D(MathUtils.roundTo(x, res), yy); if (poly.containsPoint(p)) { points.add(p); } } } return points; } }
Version data entries
11 entries across 11 versions & 1 rubygems