public final class Circle extends AbstractNSphere<Vector2D> implements Linecastable2D
Modifier and Type | Method and Description |
---|---|
Vector2D |
firstIntersection(Line line)
Get the first intersection point between the given line and this circle, or null
if no such point exists.
|
static Circle |
from(Vector2D center,
double radius,
Precision.DoubleEquivalence precision)
Construct a circle from a center point and radius.
|
double |
getBoundarySize() |
double |
getSize() |
List<Vector2D> |
intersections(Line line)
Get the intersections of the given line with this circle.
|
List<LinecastPoint2D> |
linecast(LineConvexSubset segment)
Intersect the given line subset against the boundaries in this instance, returning
a list of all intersections in order of increasing position along the line.
|
LinecastPoint2D |
linecastFirst(LineConvexSubset segment)
Intersect the given line subset against the boundaries in this instance, returning
the first intersection found when traveling in the direction of the line subset
from its start location.
|
Vector2D |
project(Vector2D pt) |
RegionBSPTree2D |
toTree(int segments)
Return a
RegionBSPTree2D representing an approximation of the circle. |
classify, equals, firstIntersection, getCenter, getCentroid, getPrecision, getRadius, hashCode, intersections, isEmpty, isFull, project, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
linecast, linecastFirst
isFinite, isInfinite
public double getBoundarySize()
getBoundarySize
in interface Region<Vector2D>
public RegionBSPTree2D toTree(int segments)
RegionBSPTree2D
representing an approximation of the circle.
All points in the approximation are contained in the circle (ie, they lie inside
or on the boundary). No guarantees are made regarding the internal structure of
the returned tree. Non-boundary split nodes may be used in order to balance the tree
and improve performance.
Choosing an appropriate number of segments for an approximation is a trade-off between size and accuracy: approximations with large numbers of segments more closely match the geometric properties of the circle but at the cost of using larger tree structures. In general, the smallest number of segments that produces an acceptable result should be used.
segments
- number of line segments to use for the boundary of
the circle approximationIllegalArgumentException
- if segments
is less than 3public List<Vector2D> intersections(Line line)
line
- line to intersect with the circlepublic Vector2D firstIntersection(Line line)
line
- line to intersect with the circlepublic List<LinecastPoint2D> linecast(LineConvexSubset segment)
linecast
in interface Linecastable2D
segment
- line subset to intersectpublic LinecastPoint2D linecastFirst(LineConvexSubset segment)
linecastFirst
in interface Linecastable2D
segment
- line subset to intersectpublic static Circle from(Vector2D center, double radius, Precision.DoubleEquivalence precision)
center
- the center point of the circleradius
- the circle radiusprecision
- precision precision context used to compare floating point numbersIllegalArgumentException
- if center is not finite or radius is not finite or is
less than or equal to zero as evaluated by the given precision contextCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.