Class Circle.CircleApproximationBuilder
java.lang.Object
org.apache.commons.geometry.euclidean.twod.shape.Circle.CircleApproximationBuilder
- Enclosing class:
Circle
Class used to build BSP tree circle approximations. Structural BSP tree cuts are
used to help balance the tree and improve performance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
Angle delta between vertex points.private final Circle
Circle being approximated.private static final int
The minimum number of segments required to create a circle approximation.private final int
Number of boundary segments in the approximation.private static final int
Minimum number of line segments in a portion of the approximation in order to allow a structural BSP split. -
Constructor Summary
ConstructorsConstructorDescriptionCircleApproximationBuilder
(Circle circle, int segments) Create a new instance for approximating the given circle. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the BSP tree circle approximation.private void
insert
(RegionBSPTree2D.RegionNode2D node, int startIdx, int stopIdx) Insert boundary segments into the given node.private Vector2D
pointAt
(int idx) Get the boundary vertex point at the given index.private void
splitAndInsert
(RegionBSPTree2D.RegionNode2D node, int startIdx, int stopIdx) Split the given node if possible and recursively add boundary segments.
-
Field Details
-
MIN_SEGMENTS
private static final int MIN_SEGMENTSThe minimum number of segments required to create a circle approximation.- See Also:
-
SPLIT_THRESHOLD
private static final int SPLIT_THRESHOLDMinimum number of line segments in a portion of the approximation in order to allow a structural BSP split.- See Also:
-
circle
Circle being approximated. -
segments
private final int segmentsNumber of boundary segments in the approximation. -
angleDelta
private final double angleDeltaAngle delta between vertex points.
-
-
Constructor Details
-
CircleApproximationBuilder
CircleApproximationBuilder(Circle circle, int segments) Create a new instance for approximating the given circle.- Parameters:
circle
- circle to approximatesegments
- number of boundary segments in the approximation- Throws:
IllegalArgumentException
- ifsegments
is less than 3
-
-
Method Details
-
build
Build the BSP tree circle approximation.- Returns:
- the BSP tree circle approximation
-
splitAndInsert
Split the given node if possible and recursively add boundary segments.- Parameters:
node
- current tree nodestartIdx
- index of the start point for this node's boundary segmentsstopIdx
- index of the end point for this node's boundary segments
-
insert
Insert boundary segments into the given node. No structural splits are created.- Parameters:
node
- current tree nodestartIdx
- index of the start point for this node's boundary segmentsstopIdx
- index of the end point for this node's boundary segments
-
pointAt
Get the boundary vertex point at the given index.- Parameters:
idx
- vertex point index- Returns:
- the vertex point at the given index
-