Package org.locationtech.jts.algorithm
Class MinimumBoundingCircle
- java.lang.Object
-
- org.locationtech.jts.algorithm.MinimumBoundingCircle
-
public class MinimumBoundingCircle extends java.lang.Object
Computes the Minimum Bounding Circle (MBC) for the points in aGeometry
. The MBC is the smallest circle which covers all the input points (this is also known as the Smallest Enclosing Circle). This is equivalent to computing the Maximum Diameter of the input point set.The computed circle can be specified in two equivalent ways, both of which are provide as output by this class:
- As a centre point and a radius
- By the set of points defining the circle.
Depending on the number of points in the input
and their relative positions, this
will be specified by anywhere from 0 to 3 points.
- 0 or 1 points indicate an empty or trivial input point arrangement.
- 2 or 3 points define a circle which contains all the input points.
Geometry
which approximates the shape of the MBC (although as an approximation it is not guaranteed to cover all the input points.)- See Also:
MinimumDiameter
-
-
Field Summary
Fields Modifier and Type Field Description private Coordinate
centre
private Coordinate[]
extremalPts
private Geometry
input
private double
radius
-
Constructor Summary
Constructors Constructor Description MinimumBoundingCircle(Geometry geom)
Creates a new object for computing the minimum bounding circle for the point set defined by the vertices of the given geometry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
compute()
private void
computeCentre()
private void
computeCirclePoints()
Coordinate
getCentre()
Gets the centre point of the computed Minimum Bounding Circle.Geometry
getCircle()
Gets a geometry which represents the Minimum Bounding Circle.Geometry
getDiameter()
Gets a geometry representing the diameter of the computed Minimum Bounding Circle.Coordinate[]
getExtremalPoints()
Gets the extremal points which define the computed Minimum Bounding Circle.Geometry
getFarthestPoints()
Gets a geometry representing a line between the two farthest points in the input.double
getRadius()
Gets the radius of the computed Minimum Bounding Circle.private static Coordinate
lowestPoint(Coordinate[] pts)
private static Coordinate
pointWithMinAngleWithSegment(Coordinate[] pts, Coordinate P, Coordinate Q)
private static Coordinate
pointWitMinAngleWithX(Coordinate[] pts, Coordinate P)
-
-
-
Field Detail
-
input
private Geometry input
-
extremalPts
private Coordinate[] extremalPts
-
centre
private Coordinate centre
-
radius
private double radius
-
-
Constructor Detail
-
MinimumBoundingCircle
public MinimumBoundingCircle(Geometry geom)
Creates a new object for computing the minimum bounding circle for the point set defined by the vertices of the given geometry.- Parameters:
geom
- the geometry to use to obtain the point set
-
-
Method Detail
-
getCircle
public Geometry getCircle()
Gets a geometry which represents the Minimum Bounding Circle. If the input is degenerate (empty or a single unique point), this method will return an empty geometry or a single Point geometry. Otherwise, a Polygon will be returned which approximates the Minimum Bounding Circle. (Note that because the computed polygon is only an approximation, it may not precisely contain all the input points.)- Returns:
- a Geometry representing the Minimum Bounding Circle.
-
getFarthestPoints
public Geometry getFarthestPoints()
Gets a geometry representing a line between the two farthest points in the input. These points will be two of the extremal points of the Minimum Bounding Circle. They also lie on the convex hull of the input.- Returns:
- a LineString between the two farthest points of the input
-
getDiameter
public Geometry getDiameter()
Gets a geometry representing the diameter of the computed Minimum Bounding Circle.- Returns:
- the diameter LineString of the Minimum Bounding Circle
-
getExtremalPoints
public Coordinate[] getExtremalPoints()
Gets the extremal points which define the computed Minimum Bounding Circle. There may be zero, one, two or three of these points, depending on the number of points in the input and the geometry of those points.- Returns:
- the points defining the Minimum Bounding Circle
-
getCentre
public Coordinate getCentre()
Gets the centre point of the computed Minimum Bounding Circle.- Returns:
- the centre point of the Minimum Bounding Circle
-
getRadius
public double getRadius()
Gets the radius of the computed Minimum Bounding Circle.- Returns:
- the radius of the Minimum Bounding Circle
-
computeCentre
private void computeCentre()
-
compute
private void compute()
-
computeCirclePoints
private void computeCirclePoints()
-
lowestPoint
private static Coordinate lowestPoint(Coordinate[] pts)
-
pointWitMinAngleWithX
private static Coordinate pointWitMinAngleWithX(Coordinate[] pts, Coordinate P)
-
pointWithMinAngleWithSegment
private static Coordinate pointWithMinAngleWithSegment(Coordinate[] pts, Coordinate P, Coordinate Q)
-
-