Package com.irurueta.geometry
Class Circle
java.lang.Object
com.irurueta.geometry.Circle
- All Implemented Interfaces:
Serializable
This class defines a circle.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Point2DCenter of circle.static final doubleConstant defining default threshold value used when none is provided.static final doubleConstant defining machine precision.static final doubleConstant defining minimum allowed radius.static final doubleConstant defining minimum allowed threshold.private doubleRadius of circle. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublearea(double radius) Returns area of a circle having provided radius.voidclosestPoint(Point2D point, Point2D result) Computes closest point to provided point that is located in this circle boundary and stores the result in provided result instance.static doublecurvature(double radius) Gets curvature for provided radius.static doubleReturns distance from provided point to the closest point located in provided circle boundary.doublegetArea()Returns area of this circle.Returns center of circle.getClosestPoint(Point2D point) Returns closest point to provided point that is located in this circle boundary.doubleGets curvature of radius at provided point.doublegetDistance(Point2D point) Returns distance from provided point to the closest point located in the circle boundary.doubleReturns perimeter of this circle.doubleReturns radius of circle.doublegetSignedDistance(Point2D point) Returns distance from provided point to the closest point located in the circle boundary.getTangentLineAt(Point2D point) Returns a line tangent to this circle at provided point.getTangentLineAt(Point2D point, double threshold) Returns a line tangent to this circle at provided point.booleanDetermines if provided point is inside this circle or not.booleanDetermines if provided point is inside this circle or not up to a certain threshold.booleanDetermines whether provided point lies at circle boundary or not.booleanDetermines whether provided point lies at circle boundary or not up to a certain threshold.static doubleperimeter(double radius) Returns perimeter of a circle having provided radius.voidSets center of circle.final voidsetCenterAndRadius(Point2D center, double radius) Sets center and radius of this circle.final voidsetFromConic(Conic conic) Set parameters of this circle from a valid conic corresponding to a circle.final voidsetParametersFromPoints(Point2D point1, Point2D point2, Point2D point3) Sets parameters of a circle by using three points that must belong to its locus.voidsetRadius(double radius) Sets radius of circle.static doublesignedDistance(Circle circle, Point2D point) Returns distance from provided point to the closest point located in provided circle boundary.voidtangentLineAt(Point2D point, Line2D line, double threshold) Computes a line tangent to this circle at provided point.toConic()Converts this circle into a conic.
-
Field Details
-
MIN_RADIUS
public static final double MIN_RADIUSConstant defining minimum allowed radius.- See Also:
-
DEFAULT_THRESHOLD
public static final double DEFAULT_THRESHOLDConstant defining default threshold value used when none is provided.- See Also:
-
MIN_THRESHOLD
public static final double MIN_THRESHOLDConstant defining minimum allowed threshold.- See Also:
-
EPS
public static final double EPSConstant defining machine precision.- See Also:
-
center
Center of circle. -
radius
private double radiusRadius of circle.
-
-
Constructor Details
-
Circle
public Circle()Empty constructor. Creates circle located at space origin (0,0) with radius 1.0. -
Circle
Constructor. Sets center and radius of circle.- Parameters:
center- Center of circle.radius- Radius of circle.- Throws:
IllegalArgumentException- Raised if provided radius is negative.
-
Circle
Constructor. Computes a circle by using three points that must belong to its locus.- Parameters:
point1- point 1.point2- point 2.point3- point 3.- Throws:
ColinearPointsException- if provided set of points are coincident or co-linear (form a single line). In such cases a singularity occurs since a circle having an infinite radius would be required to contain all three points in its locus.
-
Circle
Constructor. Computes a circle from a valid conic corresponding to a circle.- Parameters:
conic- a conic to create a circle from.- Throws:
IllegalArgumentException- if provided conic is not a circle.
-
-
Method Details
-
getCenter
Returns center of circle.- Returns:
- Center of circle.
-
setCenter
Sets center of circle.- Parameters:
center- Center of circle.- Throws:
NullPointerException- Raised if provided center is null.
-
getRadius
public double getRadius()Returns radius of circle.- Returns:
- Radius of circle.
-
setRadius
public void setRadius(double radius) Sets radius of circle.- Parameters:
radius- Radius of circle.- Throws:
IllegalArgumentException- Raised if provided radius is negative.
-
setCenterAndRadius
Sets center and radius of this circle.- Parameters:
center- Center to be set.radius- Radius to be set.- Throws:
IllegalArgumentException- Raised if provided radius is negative.NullPointerException- Raised if provided center is null.
-
setParametersFromPoints
public final void setParametersFromPoints(Point2D point1, Point2D point2, Point2D point3) throws ColinearPointsException Sets parameters of a circle by using three points that must belong to its locus.- Parameters:
point1- point 1.point2- point 2.point3- point 3.- Throws:
ColinearPointsException- if provided set of points are coincident or co-linear (form a single line). In such cases a singularity occurs since a circle having an infinite radius would be required to contain all three points in its locus.
-
area
public static double area(double radius) Returns area of a circle having provided radius.- Parameters:
radius- Radius of a circle.- Returns:
- Area of a circle having provided radius.
- Throws:
IllegalArgumentException- Raised if provided radius is negative.
-
getArea
public double getArea()Returns area of this circle.- Returns:
- Area of this circle.
-
perimeter
public static double perimeter(double radius) Returns perimeter of a circle having provided radius.- Parameters:
radius- Radius of a circle.- Returns:
- Perimeter of a circle having provided radius.
- Throws:
IllegalArgumentException- Raised if provided radius is negative.
-
getPerimeter
public double getPerimeter()Returns perimeter of this circle.- Returns:
- Perimeter of this circle.
-
curvature
public static double curvature(double radius) Gets curvature for provided radius. Curvature of a circle is always the reciprocal of its radius.- Parameters:
radius- radius of a circle.- Returns:
- curvature of a circle.
-
getCurvature
public double getCurvature()Gets curvature of radius at provided point. Curvature of a circle is always the reciprocal of its radius.- Returns:
- curvature of circle.
-
isInside
Determines if provided point is inside this circle or not up to a certain threshold. If provided threshold is positive, the circle behaves as if it was a larger circle increased by threshold amount, if provided threshold is negative, the circle behaves as if it was a smaller circle decreased by threshold amount in radius.- Parameters:
point- Point to be checked.threshold- Threshold to determine if point is inside or not.- Returns:
- True if point is considered to be inside this circle, false otherwise.
-
isInside
Determines if provided point is inside this circle or not.- Parameters:
point- Point to be checked.- Returns:
- True if point is considered to be inside this circle, false otherwise.
-
getSignedDistance
Returns distance from provided point to the closest point located in the circle boundary. Returned distance will be negative when point is inside of circle, and positive otherwise.- Parameters:
point- Point to be checked.- Returns:
- Distance from point to circle boundary.
-
signedDistance
Returns distance from provided point to the closest point located in provided circle boundary. Returned distance will be negative when point is inside of circle, and positive otherwise.- Parameters:
circle- A circle.point- Point to be checked.- Returns:
- Distance from point to provided circle boundary.
-
getDistance
Returns distance from provided point to the closest point located in the circle boundary.- Parameters:
point- Point to be checked.- Returns:
- Distance from point to circle boundary.
-
distance
Returns distance from provided point to the closest point located in provided circle boundary.- Parameters:
circle- A circle.point- Point to be checked.- Returns:
- Distance from point to provided circle boundary.
-
getClosestPoint
Returns closest point to provided point that is located in this circle boundary.- Parameters:
point- A point to be checked.- Returns:
- Closest point laying in circle boundary.
- Throws:
UndefinedPointException- Raised if provided point is at circle center or very close to it.
-
closestPoint
Computes closest point to provided point that is located in this circle boundary and stores the result in provided result instance.- Parameters:
point- A point to be checked.result- Instance where result will be stored.- Throws:
UndefinedPointException- Raised if provided point is at circle center or very close to ti.
-
isLocus
Determines whether provided point lies at circle boundary or not up to a certain threshold.- Parameters:
point- Point to be checked.threshold- A small threshold to determine whether point lies at circle boundary.- Returns:
- True if point lies at circle boundary, false otherwise.
- Throws:
IllegalArgumentException- Raised if provided threshold is negative.
-
isLocus
Determines whether provided point lies at circle boundary or not.- Parameters:
point- Point to be checked.- Returns:
- True if point lies at circle boundary, false otherwise.
-
getTangentLineAt
Returns a line tangent to this circle at provided point. Provided point must be locus of this circle, otherwise a NotLocusException will be thrown.- Parameters:
point- a locus point of this circle.- Returns:
- a 2D line tangent to this circle at provided point.
- Throws:
NotLocusException- if provided point is not locus of this circle up to DEFAULT_THRESHOLD.
-
getTangentLineAt
Returns a line tangent to this circle at provided point. Provided point must be locus of this circle, otherwise a NotLocusException will be thrown.- Parameters:
point- a locus point of this circle.threshold- threshold to determine if provided point is locus.- Returns:
- a 2D line tangent to this circle at provided point.
- Throws:
NotLocusException- if provided point is not locus of this circle up to provided threshold.IllegalArgumentException- if provided threshold is negative.
-
tangentLineAt
Computes a line tangent to this circle at provided point. Provided point must be locus of this circle, otherwise a NotLocusException will be thrown.- Parameters:
point- a locus point of this circle.line- instance of a 2D line where result will be stored.threshold- threshold to determine if provided point is locus.- Throws:
NotLocusException- if provided point is not locus of this circle up to provided threshold.IllegalArgumentException- if provided threshold is negative.
-
toConic
Converts this circle into a conic. Conics are a more general representation of circles.- Returns:
- A conic representing this circle.
-
setFromConic
Set parameters of this circle from a valid conic corresponding to a circle.- Parameters:
conic- conic to set parameters from.- Throws:
IllegalArgumentException- if provided conic is not a circle.
-