Package org.geolatte.geom
Class Circle
- java.lang.Object
-
- org.geolatte.geom.Circle
-
public class Circle extends Object
This class provides operations for handling the usage of Circles and arcs in Geometries.- Author:
- Tom Acree
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCircle.ArcAn arc, or circle segment
-
Constructor Summary
Constructors Modifier Constructor Description protectedCircle()Creates a circle whose center is at the origin and whose radius is 0.Circle(double xCenter, double yCenter, double radius)Create a circle using the x/y coordinates for the center.Circle(double xLeft, double yUpper, double xRight, double yLower)Creates a circle based on bounding box.Circle(double x1, double y1, double x2, double y2, double x3, double y3)Three point method of circle construction.Circle(org.locationtech.jts.geom.Coordinate center, double radius)Create a circle with a defined center and radiusCircle(org.locationtech.jts.geom.Coordinate point1, org.locationtech.jts.geom.Coordinate point2, org.locationtech.jts.geom.Coordinate point3)Three point method of circle construction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Circle.ArccreateArc(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.geom.Coordinate p3)Creates an arc through the specified pointsdoubledistanceFromCenter(org.locationtech.jts.geom.Coordinate p)Returns the distance the point is from the center of the circlebooleanequals(Object o)doublegetAngle(org.locationtech.jts.geom.Coordinate p)Returns the angle of the point from the center and the horizontal line from the center.org.locationtech.jts.geom.CoordinategetCenter()org.locationtech.jts.geom.CoordinategetPoint(double angle)Returns the coordinate on the circle at the specified angledoublegetRadius()inthashCode()static org.locationtech.jts.geom.Coordinate[]linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value.static org.locationtech.jts.geom.Coordinate[]linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3, double tolerence)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value.org.locationtech.jts.geom.Coordinate[]linearizeArc(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.geom.Coordinate p3, double tolerence)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value.static org.locationtech.jts.geom.Coordinate[]linearizeCircle(double x1, double y1, double x2, double y2, double x3, double y3)Given a circle defined by the 3 points, creates a linearized interpolation of the circle starting and ending on the first coordinate.voidmove(double x, double y)Moves the circle to a new centerstatic doublenormalizeAngle(double angle)Returns an angle between 0 and 2*PI.voidshift(double deltaX, double deltaY)Shifts the center of the circle by delta X and delta Ystatic doublesubtractAngles(double a1, double a2)Returns the angle between the angles a1 and a2 in radians.StringtoString()
-
-
-
Constructor Detail
-
Circle
protected Circle()
Creates a circle whose center is at the origin and whose radius is 0.
-
Circle
public Circle(org.locationtech.jts.geom.Coordinate center, double radius)Create a circle with a defined center and radius- Parameters:
center- The coordinate representing the center of the circleradius- The radius of the circle
-
Circle
public Circle(double xCenter, double yCenter, double radius)Create a circle using the x/y coordinates for the center.- Parameters:
xCenter- The x coordinate of the circle's centeryCenter- The y coordinate of the circle's centerradius- the radius of the circle
-
Circle
public Circle(double xLeft, double yUpper, double xRight, double yLower)Creates a circle based on bounding box. It is possible for the user of this class to pass bounds to this method that do not represent a square. If this is the case, we must force the bounding rectangle to be a square. To this end, we check the box and set the side of the box to the larger dimension of the rectangle- Parameters:
xLeft- The leftmost x coordinateyUpper- The uppermost y coordinatexRight- The rightmost x coordinateyLower- The lowest y coordinate
-
Circle
public Circle(org.locationtech.jts.geom.Coordinate point1, org.locationtech.jts.geom.Coordinate point2, org.locationtech.jts.geom.Coordinate point3)Three point method of circle construction. All three points must be on the circumference of the circle.- Parameters:
point1- The first pointpoint2- The second pointpoint3- The third point
-
Circle
public Circle(double x1, double y1, double x2, double y2, double x3, double y3)Three point method of circle construction. All three points must be on the circumference of the circle.- Parameters:
x1- The x coordinate of the first pointy1- The y coordinate of the first pointx2- The x coordinate of the second pointy2- The y coordinate of the second pointx3- The x coordinate of the third pointy3- The y coordinate of the third point
-
-
Method Detail
-
linearizeArc
public static org.locationtech.jts.geom.Coordinate[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3, double tolerence)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value. The tolerance value specifies the maximum distance between a chord and the circle.- Parameters:
x1- x coordinate of point 1y1- y coordinate of point 1x2- x coordinate of point 2y2- y coordinate of point 2x3- x coordinate of point 3y3- y coordinate of point 3tolerence- maximum distance between the center of the chord and the outer edge of the circle- Returns:
- an ordered list of Coordinates representing a series of chords approximating the arc.
-
linearizeArc
public static org.locationtech.jts.geom.Coordinate[] linearizeArc(double x1, double y1, double x2, double y2, double x3, double y3)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value. This method uses a tolerence value of 1/100 of the length of the radius.- Parameters:
x1- x coordinate of point 1y1- y coordinate of point 1x2- x coordinate of point 2y2- y coordinate of point 2x3- x coordinate of point 3y3- y coordinate of point 3- Returns:
- an ordered list of Coordinates representing a series of chords approximating the arc.
-
linearizeCircle
public static org.locationtech.jts.geom.Coordinate[] linearizeCircle(double x1, double y1, double x2, double y2, double x3, double y3)Given a circle defined by the 3 points, creates a linearized interpolation of the circle starting and ending on the first coordinate. This method uses a tolerence value of 1/100 of the length of the radius.- Parameters:
x1- x coordinate of point 1y1- y coordinate of point 1x2- x coordinate of point 2y2- y coordinate of point 2x3- x coordinate of point 3y3- y coordinate of point 3- Returns:
- an ordered list of Coordinates representing a series of chords approximating the arc.
-
normalizeAngle
public static double normalizeAngle(double angle)
Returns an angle between 0 and 2*PI. For example, 4*PI would get returned as 2*PI since they are equivalent.- Parameters:
angle- an angle in radians to normalize- Returns:
- an angle between 0 and 2*PI
-
subtractAngles
public static double subtractAngles(double a1, double a2)Returns the angle between the angles a1 and a2 in radians. Angle is calculated in the counterclockwise direction.- Parameters:
a1- first anglea2- second angle- Returns:
- the angle between a1 and a2 in the clockwise direction
-
shift
public void shift(double deltaX, double deltaY)Shifts the center of the circle by delta X and delta Y- Parameters:
deltaX- The shift along the X-coordinate axisdeltaY- The shift along the Y-coordinate axis
-
move
public void move(double x, double y)Moves the circle to a new center- Parameters:
x- The x coordinate of the new centery- The y coordinate of the new center
-
getCenter
public org.locationtech.jts.geom.Coordinate getCenter()
-
getRadius
public double getRadius()
-
linearizeArc
public org.locationtech.jts.geom.Coordinate[] linearizeArc(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.geom.Coordinate p3, double tolerence)Given 2 points defining an arc on the circle, interpolates the circle into a collection of points that provide connected chords that approximate the arc based on the tolerance value. The tolerance value specifies the maximum distance between a chord and the circle.- Parameters:
p1- begin coordinate of the arcp2- any other point on the arcp3- end coordinate of the arctolerence- maximum distance between the center of the chord and the outer edge of the circle- Returns:
- an ordered list of Coordinates representing a series of chords approximating the arc.
-
getAngle
public double getAngle(org.locationtech.jts.geom.Coordinate p)
Returns the angle of the point from the center and the horizontal line from the center.- Parameters:
p- a point in space- Returns:
- The angle of the point from the center of the circle
-
getPoint
public org.locationtech.jts.geom.Coordinate getPoint(double angle)
Returns the coordinate on the circle at the specified angle- Parameters:
angle- The angle- Returns:
- Coordinate
-
distanceFromCenter
public double distanceFromCenter(org.locationtech.jts.geom.Coordinate p)
Returns the distance the point is from the center of the circle- Parameters:
p- A point in space- Returns:
- The distance the point is from the center of the circle
-
createArc
public Circle.Arc createArc(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.geom.Coordinate p3)
Creates an arc through the specified points- Parameters:
p1- The first pointp2- The second pointp3- The third point- Returns:
- The
Arcthrough the three points
-
-