Package georegression.geometry
Class UtilPolygons2D_F32
java.lang.Object
georegression.geometry.UtilPolygons2D_F32
@Generated("georegression.geometry.UtilPolygons2D_F64")
public class UtilPolygons2D_F32
extends Object
Various functions related to polygons.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
averageOfClosestPointError
(Polygon2D_F32 model, Polygon2D_F32 target, int numberOfSamples) Compute the error as a function of the distance between the model and target.static Rectangle2D_I32
bounding
(Polygon2D_F32 polygon, @Nullable Rectangle2D_I32 aabb) Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises.static void
bounding
(Polygon2D_F32 polygon, Rectangle2D_F32 rectangle) Finds the minimum area bounding rectangle around the quadrilateral that is aligned with coordinate system axises.static void
bounding
(Quadrilateral_F32 quad, Rectangle2D_F32 rectangle) Finds the minimum area bounding rectangle around the quadrilateral.static Point2D_F32
center
(Quadrilateral_F32 quad, @Nullable Point2D_F32 center) Computes the center or average point in the quadrilateral.static void
convert
(Polygon2D_F32 input, Quadrilateral_F32 output) Converts a polygon into a quadrilateralstatic void
convert
(Quadrilateral_F32 input, Polygon2D_F32 output) Converts a quadrilateral into a polygonstatic void
convert
(Rectangle2D_F32 input, Polygon2D_F32 output) Converts a rectangle into a polygonstatic void
convert
(Rectangle2D_F32 input, Quadrilateral_F32 output) Converts a rectangle into a quadrilateralstatic void
convert
(RectangleLength2D_I32 input, Quadrilateral_F32 output) Converts a rectangle into a quadrilateralstatic void
Flips the order of points inside the polygon.static boolean
hasAdjacentDuplicates
(Polygon2D_F32 polygon, float tol) Remove a point if it's identical to a neighborstatic boolean
isCCW
(Polygon2D_F32 polygon) static boolean
isCCW
(List<Point2D_F32> polygon) Returns true if the polygon is ordered in a counter-clockwise order.static boolean
isConvex
(Polygon2D_F32 poly) Determines if the polugon is convex or concave.static boolean
isEquivalent
(Polygon2D_F32 a, Polygon2D_F32 b, float 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 boolean
isIdentical
(Polygon2D_F32 a, Polygon2D_F32 b, float tol) Checks to see if the vertexes of the two polygon's are the same up to the specified tolerancestatic boolean
isSelfIntersectingBrute
(Polygon2D_F32 p, float tol) Brute force algorithm which checks for self intersection.static PolygonInfo
isSimple
(Polygon2D_F32 p, @Nullable PolygonInfo result, float tol) Checks to see if a polygon is simple or not, see [1].static void
removeAdjacentDuplicates
(Polygon2D_F32 polygon, float tol) Remove a point if it's identical to a neighborstatic void
removeAlmostParallel
(Polygon2D_F32 polygon, float tol) Removes a node from a polygon if the two lines its attached two are almost parallelstatic void
Shifts all the vertexes in the polygon up one element.static void
Shifts all the vertexes in the polygon up one element.static void
triangulate
(Polygon2D_F32 p, DogArray<ThreeIndexes> triangles) Triangulates the simple polygon in O(N^2).static void
vertexAverage
(Polygon2D_F32 input, Point2D_F32 average) Computes the average of all the vertexes
-
Constructor Details
-
UtilPolygons2D_F32
public UtilPolygons2D_F32()
-
-
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_F32 p, @Nullable @Nullable PolygonInfo result, float tol) Checks to see if a polygon is simple or not, see [1]. If complex then the[1] Numerical Recipes. Third Edition. Section 21.4f
- 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_F32. Modified.
-
convert
Converts a quadrilateral into a polygon- Parameters:
input
- Quadrilateral.output
- Polygon2D_F32. 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_F32 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 float averageOfClosestPointError(Polygon2D_F32 model, Polygon2D_F32 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
-