Class Circle.CircleApproximationBuilder

java.lang.Object
org.apache.commons.geometry.euclidean.twod.shape.Circle.CircleApproximationBuilder
Enclosing class:
Circle

private static class Circle.CircleApproximationBuilder extends Object
Class used to build BSP tree circle approximations. Structural BSP tree cuts are used to help balance the tree and improve performance.
  • Field Details

    • MIN_SEGMENTS

      private static final int MIN_SEGMENTS
      The minimum number of segments required to create a circle approximation.
      See Also:
    • SPLIT_THRESHOLD

      private static final int SPLIT_THRESHOLD
      Minimum number of line segments in a portion of the approximation in order to allow a structural BSP split.
      See Also:
    • circle

      private final Circle circle
      Circle being approximated.
    • segments

      private final int segments
      Number of boundary segments in the approximation.
    • angleDelta

      private final double angleDelta
      Angle 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 approximate
      segments - number of boundary segments in the approximation
      Throws:
      IllegalArgumentException - if segments is less than 3
  • Method Details

    • build

      public RegionBSPTree2D build()
      Build the BSP tree circle approximation.
      Returns:
      the BSP tree circle approximation
    • splitAndInsert

      private void splitAndInsert(RegionBSPTree2D.RegionNode2D node, int startIdx, int stopIdx)
      Split the given node if possible and recursively add boundary segments.
      Parameters:
      node - current tree node
      startIdx - index of the start point for this node's boundary segments
      stopIdx - index of the end point for this node's boundary segments
    • insert

      private void insert(RegionBSPTree2D.RegionNode2D node, int startIdx, int stopIdx)
      Insert boundary segments into the given node. No structural splits are created.
      Parameters:
      node - current tree node
      startIdx - index of the start point for this node's boundary segments
      stopIdx - index of the end point for this node's boundary segments
    • pointAt

      private Vector2D pointAt(int idx)
      Get the boundary vertex point at the given index.
      Parameters:
      idx - vertex point index
      Returns:
      the vertex point at the given index