Class Planes.PlaneBuilder
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.threed.Planes.PlaneBuilder
-
- Enclosing class:
- Planes
private static final class Planes.PlaneBuilder extends java.lang.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
crossSumX
The x component of the sum of all cross products from adjacent vectors in the point sequence.private double
crossSumY
The y component of the sum of all cross products from adjacent vectors in the point sequence.private double
crossSumZ
The z component of the sum of all cross products from adjacent vectors in the point sequence.private Vector3D.Unit
normal
The computednormal
vector for the plane.private org.apache.commons.numbers.core.Precision.DoubleEquivalence
precision
Precision context used for floating point comparisons.private Vector3D
prevPt
The previous point from the point sequence.private Vector3D
prevVector
The previous vector from the point sequence, preceding from thestartPt
toprevPt
.private java.util.Collection<? extends Vector3D>
pts
The point sequence to build a plane for.private boolean
requireConvex
If true, an exception will be thrown if the point sequence is discovered to be non-convex.private Vector3D
startPt
The start point from the point sequence.private java.util.List<? super Vector3D>
uniqueVertexOutput
List that unique vertices discovered in the input sequence will be added to.
-
Constructor Summary
Constructors Constructor Description PlaneBuilder(java.util.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) Plane
build()
Build a plane from the configured point sequence.(package private) Plane
buildForConvexPolygon(java.util.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
createPlane()
Construct the plane instance using the value gathered during point processing.private java.lang.IllegalArgumentException
nonConvex()
Return an exception with a message stating that the points given to this builder do not define a convex region.private java.lang.IllegalArgumentException
nonPlanar()
Return an exception with a message stating that the points given to this builder do not define a plane.private void
processCrossProduct(Vector3D cross)
Process the computed cross product of two vectors from the input point sequence.private void
processPoint(Vector3D pt)
Process a point from the point sequence.
-
-
-
Field Detail
-
pts
private final java.util.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 thestartPt
toprevPt
.
-
normal
private Vector3D.Unit normal
The computednormal
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 java.util.List<? super Vector3D> uniqueVertexOutput
List that unique vertices discovered in the input sequence will be added to.
-
-
Constructor Detail
-
PlaneBuilder
PlaneBuilder(java.util.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 sequenceprecision
- precision context used to perform floating point comparisons
-
-
Method Detail
-
build
Plane build()
Build a plane from the configured point sequence.- Returns:
- a plane built from the configured point sequence
- Throws:
java.lang.IllegalArgumentException
- if the points do not define a plane
-
buildForConvexPolygon
Plane buildForConvexPolygon(java.util.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:
java.lang.IllegalArgumentException
- if the points do not define a plane or therequireConvex
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:
java.lang.IllegalArgumentException
- if the points do not define a plane or therequireConvex
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:
java.lang.IllegalArgumentException
- if the points do not define a plane or therequireConvex
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:
java.lang.IllegalArgumentException
- if the point do not define a plane
-
nonPlanar
private java.lang.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 java.lang.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
-
-