Package georegression.geometry
Class UtilPolygons2D_F64
java.lang.Object
georegression.geometry.UtilPolygons2D_F64
Various functions related to polygons.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleaverageOfClosestPointError(Polygon2D_F64 model, Polygon2D_F64 target, int numberOfSamples) Compute the error as a function of the distance between the model and target.static Rectangle2D_I32bounding(Polygon2D_F64 polygon, @Nullable Rectangle2D_I32 aabb) Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises.static voidbounding(Polygon2D_F64 polygon, Rectangle2D_F64 rectangle) Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises.static voidbounding(Quadrilateral_F64 quad, Rectangle2D_F64 rectangle) Finds the minimum area bounding rectangle around the quadrilateral.static Point2D_F64center(Quadrilateral_F64 quad, @Nullable Point2D_F64 center) Computes the center or average point in the quadrilateral.static voidconvert(Polygon2D_F64 input, Quadrilateral_F64 output) Converts a polygon into a quadrilateralstatic voidconvert(Quadrilateral_F64 input, Polygon2D_F64 output) Converts a quadrilateral into a polygonstatic voidconvert(Rectangle2D_F64 input, Polygon2D_F64 output) Converts a rectangle into a polygonstatic voidconvert(Rectangle2D_F64 input, Quadrilateral_F64 output) Converts a rectangle into a quadrilateralstatic voidconvert(RectangleLength2D_I32 input, Quadrilateral_F64 output) Converts a rectangle into a quadrilateralstatic voidFlips the order of points inside the polygon.static booleanhasAdjacentDuplicates(Polygon2D_F64 polygon, double tol) Remove a point if it's identical to a neighborstatic booleanisCCW(Polygon2D_F64 polygon) static booleanisCCW(List<Point2D_F64> polygon) Returns true if the polygon is ordered in a counter-clockwise order.static booleanisConvex(Polygon2D_F64 poly) Determines if the polugon is convex or concave.static booleanisEquivalent(Polygon2D_F64 a, Polygon2D_F64 b, double tol) Checks to see if the vertexes of the two polygon's are the same up to the specified tolerance and allows for a shift in their orderstatic booleanisIdentical(Polygon2D_F64 a, Polygon2D_F64 b, double tol) Checks to see if the vertexes of the two polygon's are the same up to the specified tolerancestatic booleanisSelfIntersectingBrute(Polygon2D_F64 p, double tol) Brute force algorithm which checks for self intersection.static PolygonInfoisSimple(Polygon2D_F64 p, @Nullable PolygonInfo result, double tol) Checks to see if a polygon is simple or not, see [1].static voidremoveAdjacentDuplicates(Polygon2D_F64 polygon, double tol) Remove a point if it's identical to a neighborstatic voidremoveAlmostParallel(Polygon2D_F64 polygon, double tol) Removes a node from a polygon if the two lines its attached two are almost parallelstatic voidShifts all the vertexes in the polygon up one element.static voidShifts all the vertexes in the polygon up one element.static voidtriangulate(Polygon2D_F64 p, DogArray<ThreeIndexes> triangles) Triangulates the simple polygon in O(N^2).static voidvertexAverage(Polygon2D_F64 input, Point2D_F64 average) Computes the average of all the vertexes
-
Constructor Details
-
UtilPolygons2D_F64
public UtilPolygons2D_F64()
-
-
Method Details
-
isConvex
Determines if the polugon is convex or concave.- Parameters:
poly- Polygon- Returns:
- true if convex and false if concave
-
isSimple
public static PolygonInfo isSimple(Polygon2D_F64 p, @Nullable @Nullable PolygonInfo result, double tol) Checks to see if a polygon is simple or not, see [1]. If complex then the[1] Numerical Recipes. Third Edition. Section 21.4
- Parameters:
p- (Input) polygon.tol- (Input) tolerance for testing if lines are colinear- Returns:
- true if simple or false if complex.
-
isSelfIntersectingBrute
Brute force algorithm which checks for self intersection.- Parameters:
p- (Input) the polygontol- (Input) tolerance for testing if lines are colinear- Returns:
- true if self intersection
-
triangulate
Triangulates the simple polygon in O(N^2). Output is represented by sets of indexes where each index is the index of the vertex in the input polygon.- Parameters:
p- (Input) Polygontriangles- (Output) Triangles.- See Also:
-
convert
Converts a rectangle into a quadrilateral- Parameters:
input- Rectangle.output- Quadrilateral. Modified.
-
convert
Converts a rectangle into a polygon- Parameters:
input- Rectangle.output- Polygon2D_F64. Modified.
-
convert
Converts a quadrilateral into a polygon- Parameters:
input- Quadrilateral.output- Polygon2D_F64. Modified.
-
convert
Converts a polygon into a quadrilateral- Parameters:
input- polygon.output- Quadrilateral. Modified.
-
convert
Converts a rectangle into a quadrilateral- Parameters:
input- Rectangle.output- Quadrilateral. Modified.
-
bounding
Finds the minimum area bounding rectangle around the quadrilateral.- Parameters:
quad- (Input) Quadrilateralrectangle- (Output) Minimum area rectangle
-
bounding
Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises. This is also known as the Axis Aligned Bounding Box (AABB).- Parameters:
polygon- (Input) Polygonrectangle- (Output) Minimum area rectangle
-
bounding
public static Rectangle2D_I32 bounding(Polygon2D_F64 polygon, @Nullable @Nullable Rectangle2D_I32 aabb) Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises. This is also known as the Axis Aligned Bounding Box (AABB).- Parameters:
polygon- (Input) Polygonaabb- (Output) Minimum area rectangle a.k.a. AABB. lower extent is inclusive, upper is exclusive.
-
center
Computes the center or average point in the quadrilateral.- Parameters:
quad- (Input) Quadrilateralcenter- (output) Center point of the quadrilateral. Can be null.- Returns:
- The center point.
-
isCCW
Returns true if the polygon is ordered in a counter-clockwise order. This is done by summing up the interior angles.- Parameters:
polygon- List of ordered points which define a polygon- Returns:
- true if CCW and false if CW
-
isCCW
-
vertexAverage
Computes the average of all the vertexes- Parameters:
input- (input) polygonaverage- (output) average point
-
isIdentical
Checks to see if the vertexes of the two polygon's are the same up to the specified tolerance- Parameters:
a- Polygonb- Polygontol- tolerance- Returns:
- true if identical up to tolerance or false if not
-
isEquivalent
Checks to see if the vertexes of the two polygon's are the same up to the specified tolerance and allows for a shift in their order- Parameters:
a- Polygonb- Polygontol- tolerance- Returns:
- true if identical up to tolerance or false if not
-
flip
Flips the order of points inside the polygon. The first index will remain the same will otherwise be reversed- Parameters:
a- Polygon of order 3 or more.
-
shiftUp
Shifts all the vertexes in the polygon up one element. Wraps around at the end- Parameters:
a- Polygon
-
shiftDown
Shifts all the vertexes in the polygon up one element. Wraps around at the end- Parameters:
a- Polygon
-
removeAlmostParallel
Removes a node from a polygon if the two lines its attached two are almost parallel- Parameters:
polygon- The polygon being modifiedtol- Tolerance in radians
-
removeAdjacentDuplicates
Remove a point if it's identical to a neighbor- Parameters:
polygon- The polygon being modifiedtol- Tolerance in radians
-
hasAdjacentDuplicates
Remove a point if it's identical to a neighbor- Parameters:
polygon- The polygon being modifiedtol- Tolerance in radians
-
averageOfClosestPointError
public static double averageOfClosestPointError(Polygon2D_F64 model, Polygon2D_F64 target, int numberOfSamples) Compute the error as a function of the distance between the model and target. The target is sampled at regular intervals and for each of these points the closest point on the model is found. The returned metric is the average of difference between paired points. NOTE: A different answer will be returned depending on which polygon is the model and which one is the target.- Parameters:
model- Model polygontarget- Target polygon- Returns:
- average of closest point error
-