Class Planes.PlaneBuilder

java.lang.Object
org.apache.commons.geometry.euclidean.threed.Planes.PlaneBuilder
Enclosing class:
Planes

private static final class Planes.PlaneBuilder extends Object
Internal helper class used to construct planes from sequences of points. Instances can be also be configured to collect lists of unique points found during plane construction and validate that the defined region is convex.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    The x component of the sum of all cross products from adjacent vectors in the point sequence.
    private double
    The y component of the sum of all cross products from adjacent vectors in the point sequence.
    private double
    The z component of the sum of all cross products from adjacent vectors in the point sequence.
    The computed normal vector for the plane.
    private final org.apache.commons.numbers.core.Precision.DoubleEquivalence
    Precision context used for floating point comparisons.
    private Vector3D
    The previous point from the point sequence.
    private Vector3D
    The previous vector from the point sequence, preceding from the startPt to prevPt.
    private final Collection<? extends Vector3D>
    The point sequence to build a plane for.
    private boolean
    If true, an exception will be thrown if the point sequence is discovered to be non-convex.
    private Vector3D
    The start point from the point sequence.
    private List<? super Vector3D>
    List that unique vertices discovered in the input sequence will be added to.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlaneBuilder(Collection<? extends Vector3D> pts, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
    Construct a new build instance for the given point sequence and precision context.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) Plane
    Build a plane from the configured point sequence.
    (package private) Plane
    buildForConvexPolygon(List<? super Vector3D> vertexOutput)
    Build a plane from the configured point sequence, validating that the points form a convex region and adding all discovered unique points to the given list.
    private Plane
    Construct the plane instance using the value gathered during point processing.
    Return an exception with a message stating that the points given to this builder do not define a convex region.
    Return an exception with a message stating that the points given to this builder do not define a plane.
    private void
    Process the computed cross product of two vectors from the input point sequence.
    private void
    Process a point from the point sequence.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pts

      private final Collection<? extends Vector3D> pts
      The point sequence to build a plane for.
    • precision

      private final org.apache.commons.numbers.core.Precision.DoubleEquivalence precision
      Precision context used for floating point comparisons.
    • startPt

      private Vector3D startPt
      The start point from the point sequence.
    • prevPt

      private Vector3D prevPt
      The previous point from the point sequence.
    • prevVector

      private Vector3D prevVector
      The previous vector from the point sequence, preceding from the startPt to prevPt.
    • normal

      private Vector3D.Unit normal
      The computed normal vector for the plane.
    • crossSumX

      private double crossSumX
      The x component of the sum of all cross products from adjacent vectors in the point sequence.
    • crossSumY

      private double crossSumY
      The y component of the sum of all cross products from adjacent vectors in the point sequence.
    • crossSumZ

      private double crossSumZ
      The z component of the sum of all cross products from adjacent vectors in the point sequence.
    • requireConvex

      private boolean requireConvex
      If true, an exception will be thrown if the point sequence is discovered to be non-convex.
    • uniqueVertexOutput

      private List<? super Vector3D> uniqueVertexOutput
      List that unique vertices discovered in the input sequence will be added to.
  • Constructor Details

    • PlaneBuilder

      PlaneBuilder(Collection<? extends Vector3D> pts, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Construct a new build instance for the given point sequence and precision context.
      Parameters:
      pts - point sequence
      precision - precision context used to perform floating point comparisons
  • Method Details

    • build

      Plane build()
      Build a plane from the configured point sequence.
      Returns:
      a plane built from the configured point sequence
      Throws:
      IllegalArgumentException - if the points do not define a plane
    • buildForConvexPolygon

      Plane buildForConvexPolygon(List<? super Vector3D> vertexOutput)
      Build a plane from the configured point sequence, validating that the points form a convex region and adding all discovered unique points to the given list.
      Parameters:
      vertexOutput - list that unique points discovered in the point sequence will be added to
      Returns:
      a plane created from the configured point sequence
      Throws:
      IllegalArgumentException - if the points do not define a plane or the requireConvex flag is true and the points do not define a convex area
    • processPoint

      private void processPoint(Vector3D pt)
      Process a point from the point sequence.
      Parameters:
      pt -
      Throws:
      IllegalArgumentException - if the points do not define a plane or the requireConvex flag is true and the points do not define a convex area
    • processCrossProduct

      private void processCrossProduct(Vector3D cross)
      Process the computed cross product of two vectors from the input point sequence. The vectors start at the first point in the sequence and point to adjacent points later in the sequence.
      Parameters:
      cross - the cross product of two vectors from the input point sequence
      Throws:
      IllegalArgumentException - if the points do not define a plane or the requireConvex flag is true and the points do not define a convex area
    • createPlane

      private Plane createPlane()
      Construct the plane instance using the value gathered during point processing.
      Returns:
      the created plane instance
      Throws:
      IllegalArgumentException - if the point do not define a plane
    • nonPlanar

      private IllegalArgumentException nonPlanar()
      Return an exception with a message stating that the points given to this builder do not define a plane.
      Returns:
      an exception stating that the points do not define a plane
    • nonConvex

      private IllegalArgumentException nonConvex()
      Return an exception with a message stating that the points given to this builder do not define a convex region.
      Returns:
      an exception stating that the points do not define a plane