public class TestPolygonGenerator
extends java.lang.Object
These methods will be useful for testing your hull finding algorithm. Each method returns a polygon, as an array of Point2D objects. Note that polygons are "open" (first point not repeated as last point in array).
Rounding is applied to point coordinate values to avoid potential floating-point rounding issues. (This helps eliminate precision problems when using these generated polygons with the JTS library (or your own geometry algorithms). See: https://locationtech.github.io/jts/jts-faq.html#robustness Section D).
Constructor and Description |
---|
TestPolygonGenerator() |
Modifier and Type | Method and Description |
---|---|
static Point2D[] |
collinear1()
Makes a 10 point polygon that contains some collinear points (pattern 1)
|
static Point2D[] |
collinear2()
Makes a 10 point polygon that contains some collinear points (pattern 2)
|
static Point2D[] |
randomPolyGaussian(int size)
Make a random set of points normally-distributed and centered on point (0.5,0.5).
|
static Point2D[] |
randomPolyUniform(int size)
Make a random set of points uniformly distributed within the unit square from (0,0) to (1,1).
|
public static Point2D[] collinear1()
public static Point2D[] collinear2()
public static Point2D[] randomPolyGaussian(int size)
size
- number of points in generated polygonjava.lang.IllegalArgumentException
- if size is less than 3public static Point2D[] randomPolyUniform(int size)
size
- number of point in generated polygonjava.lang.IllegalArgumentException
- if size is less than 3