Interface GeometryUtil
- Author:
- Andrey Malykhanov
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubledistanceBetweenLonLatsMeters(Point lonLat1, Point lonLat2) Calculates approximate distance between the first and the second geographical points, in meters.static doublegetAbsHeadingDifference(double heading1, double heading2) Returns the absolute smallest difference between two headings in radians.static PolylinegetArrowPolyline(Segment segment, double arrowSize) Returns a polyline of 2 segments representing the "pointing" part of the arrow at the end of the specified segment.static PolylinegetAveragePolyline(Point beginPoint, Point endPoint, List<Polyline> polylines, double averagingRadius) Returns the polyline that is the "average" polyline across the specified list of polylines.static PolygongetConvexPolygonForPoints(List<Point> points) Computes the convex hull (minimal convex polygon) for the given set of points using the Jarvis March algorithm.static Point[]getHermiteCurvePoints(Point[] basePoints, int numberOfSegments) Returns a series of points along a Hermite curve based on provided control points.static PolygongetRectangleAround(Point point, double width, double height) Returns a polygon consisting of 4 segments that is a rectangle with the specified side width and height with center at the specified point.static PolygongetRectangleByCornerPoints(Point firstCornerPoint, Point secondCornerPoint) Creates aPolygoninstance representing an axis-aligned rectangle using two opposite corner points.static doublegetRelativeHeading(double heading, double basicHeading) Calculates the relative heading based on a reference heading.static PolygongetSquareAround(Point point, double squareSide) Returns a polygon consisting of 4 segments that is a square with the specified side length with center at the specified point.static <N,A> void groupAroundNode(Graph<N, A> graph, Graph<N, A>.Node groupingNode, double radius, Function<N, Point> pointExtractor, Function<A, Polyline> polylineExtractor, BiFunction<A, Polyline, A> newArcValueSupplier) Deprecated.
-
Method Details
-
groupAroundNode
@Deprecated static <N,A> void groupAroundNode(Graph<N, A> graph, Graph<N, A>.Node groupingNode, double radius, Function<N, Point> pointExtractor, Function<A, Polyline> polylineExtractor, BiFunction<A, Polyline, A> newArcValueSupplier) Deprecated. -
getArrowPolyline
Returns a polyline of 2 segments representing the "pointing" part of the arrow at the end of the specified segment.- Parameters:
segment- the segment at whose end to create the arrowarrowSize- size of the arrow- Returns:
- polyline of 2 segments representing the "pointing" part of the arrow at the end of the specified segment
-
getHermiteCurvePoints
Returns a series of points along a Hermite curve based on provided control points. The Hermite curve is typically smooth and it passes through all the control points.The method uses a cubic polynomial formula to interpolate the points between the control points. The number of points returned will be
numberOfPoints + 1, including both the starting and ending points.- Parameters:
basePoints- An array ofPointinstances representing the control points of the curvenumberOfSegments- The number of segments between points on the curve. The actual number of points returned isnumberOfPoints + 1, including the end points.- Returns:
- An array of
Pointinstances representing the points along the Hermite curve.
-
getRelativeHeading
static double getRelativeHeading(double heading, double basicHeading) Calculates the relative heading based on a reference heading.This method adjusts a given heading relative to a 'basic' heading (or reference heading), effectively computing the angle between the two headings. The result represents the angular displacement needed to align the first heading with the second.
The method ensures that the result is a positive angle less than
2 * Math.PI.- Parameters:
heading- The heading to be adjusted, in radians.basicHeading- The reference heading from which to calculate the relative heading, in radians.- Returns:
- The adjusted heading in radians, a positive value between 0
(inclusive) and
2 * Math.PI(exclusive).
-
getAbsHeadingDifference
static double getAbsHeadingDifference(double heading1, double heading2) Returns the absolute smallest difference between two headings in radians.This method computes the absolute difference between two angular headings, taking into account the circular nature of angles. Angles are input in radians and the output is the smallest difference considering a full 360-degree rotation, where angles wrap around after
2 * Math.PIradians.- Parameters:
heading1- The first heading in radiansheading2- The second heading in radians- Returns:
- The smallest absolute difference in radians between the two headings
-
getSquareAround
Returns a polygon consisting of 4 segments that is a square with the specified side length with center at the specified point.- Parameters:
point- center of the squaresquareSide- side length of the square- Returns:
- polygon consisting of 4 segments that is a square with center at the specified point
-
getRectangleAround
Returns a polygon consisting of 4 segments that is a rectangle with the specified side width and height with center at the specified point.- Parameters:
point- center of the squarewidth- width of the rectangleheight- height of the rectangle- Returns:
- polygon consisting of 4 segments that is a rectangle with center at the specified point
-
getRectangleByCornerPoints
Creates aPolygoninstance representing an axis-aligned rectangle using two opposite corner points. The resulting polygon consists of four corners ordered to form a closed rectangle with non-zero area.- Parameters:
firstCornerPoint- the first corner point of the rectangle (order does not matter)secondCornerPoint- the second opposite corner point of the rectangle (order does not matter)- Returns:
- a
Polygonrepresenting the axis-aligned rectangle formed by the points - Throws:
IllegalArgumentException- if the two points have the same X-coordinate or Y-coordinate, which would result in a line or point (zero-area polygon)
-
getAveragePolyline
static Polyline getAveragePolyline(Point beginPoint, Point endPoint, List<Polyline> polylines, double averagingRadius) Returns the polyline that is the "average" polyline across the specified list of polylines. The resulting polyline starts at the specified begin point and ends at the specified end point. This method can returnnullif it fails to create an average polyline.
- Parameters:
beginPoint- begin point of the resulting polylineendPoint- end point of the resulting polylinepolylines- list of polylines being averagedaveragingRadius- radius of averaging. The segments of the resulting polyline will be around half of this value- Returns:
- polyline that is the "average" polyline across the specified list of polylines
-
distanceBetweenLonLatsMeters
Calculates approximate distance between the first and the second geographical points, in meters.- Parameters:
lonLat1- first geographical point (lon, lat)lonLat2- second geographical point (lon, lat)- Returns:
- Approximate distance in meters
-
getConvexPolygonForPoints
Computes the convex hull (minimal convex polygon) for the given set of points using the Jarvis March algorithm.Special cases:
- Empty polygon if input list is
nullor empty - Polygon containing the original points if the original list of points contains less than 3 points
- Parameters:
points- List of input points (may be empty ornull)- Returns:
- Polygon representing the convex hull
- Empty polygon if input list is
-