Class Planes.PlaneBuilder
java.lang.Object
org.apache.commons.geometry.euclidean.threed.Planes.PlaneBuilder
- Enclosing class:
Planes
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
FieldsModifier and TypeFieldDescriptionprivate 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.private Vector3D.Unit
The computednormal
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 thestartPt
toprevPt
.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.List that unique vertices discovered in the input sequence will be added to. -
Constructor Summary
ConstructorsConstructorDescriptionPlaneBuilder
(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 TypeMethodDescription(package private) Plane
build()
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.private IllegalArgumentException
Return an exception with a message stating that the points given to this builder do not define a convex region.private IllegalArgumentException
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 Details
-
pts
The point sequence to build a plane for. -
precision
private final org.apache.commons.numbers.core.Precision.DoubleEquivalence precisionPrecision context used for floating point comparisons. -
startPt
The start point from the point sequence. -
prevPt
The previous point from the point sequence. -
prevVector
The previous vector from the point sequence, preceding from thestartPt
toprevPt
. -
normal
The computednormal
vector for the plane. -
crossSumX
private double crossSumXThe x component of the sum of all cross products from adjacent vectors in the point sequence. -
crossSumY
private double crossSumYThe y component of the sum of all cross products from adjacent vectors in the point sequence. -
crossSumZ
private double crossSumZThe z component of the sum of all cross products from adjacent vectors in the point sequence. -
requireConvex
private boolean requireConvexIf true, an exception will be thrown if the point sequence is discovered to be non-convex. -
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 sequenceprecision
- 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
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 therequireConvex
flag is true and the points do not define a convex area
-
processPoint
Process a point from the point sequence.- Parameters:
pt
-- Throws:
IllegalArgumentException
- if the points do not define a plane or therequireConvex
flag is true and the points do not define a convex area
-
processCrossProduct
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 therequireConvex
flag is true and the points do not define a convex area
-
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
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
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
-