Class AbstractConvexPolygon3D
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.threed.AbstractPlaneSubset
-
- org.apache.commons.geometry.euclidean.threed.AbstractConvexPolygon3D
-
- All Implemented Interfaces:
HyperplaneConvexSubset<Vector3D>
,HyperplaneSubset<Vector3D>
,Splittable<Vector3D,HyperplaneSubset<Vector3D>>
,Sized
,ConvexPolygon3D
,PlaneConvexSubset
,PlaneSubset
- Direct Known Subclasses:
SimpleTriangle3D
,VertexListConvexPolygon3D
abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements ConvexPolygon3D
Abstract base class forConvexPolygon3D
implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset
PlaneConvexSubset.Embedded
-
Nested classes/interfaces inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneSubset
PlaneSubset.Embedded
-
-
Constructor Summary
Constructors Constructor Description AbstractConvexPolygon3D(Plane plane)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<Vector3D>
buildPolygonSplitVertexList(int enterIdx, Vector3D newEnterPt, int exitIdx, Vector3D newExitPt, java.util.List<? extends Vector3D> vertices)
Internal method for building a vertex list for one side of a split result.RegionLocation
classify(Vector3D pt)
Classify a point with respect to the subset region.Vector3D
closest(Vector3D pt)
Return the closest point to the argument that is contained in the subset (ie, not classified asoutside
), or null if no such point exists.Bounds3D
getBounds()
Get aBounds3D
object defining an axis-aligned bounding box containing all vertices for this subset.Vector3D
getCentroid()
Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique.PlaneConvexSubset.Embedded
getEmbedded()
Return an object containing the plane subset as an embedded 2D subspace region.Plane
getPlane()
Get the plane containing this subset.double
getSize()
Get the size of the instance.boolean
isEmpty()
Return true if this instance does not contain any points.boolean
isFull()
Return true if this instance contains all points in the hyperplane.Split<PlaneConvexSubset>
split(Hyperplane<Vector3D> splitter)
Split this instance with the given hyperplane.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.geometry.euclidean.threed.AbstractPlaneSubset
getHyperplane, intersection, intersection
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.ConvexPolygon3D
reverse, transform
-
Methods inherited from interface org.apache.commons.geometry.core.partitioning.HyperplaneSubset
contains
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset
getVertices, toConvex
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.PlaneSubset
getHyperplane, intersection, intersection, toTriangles
-
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
-
-
-
Field Detail
-
plane
private final Plane plane
Plane containing the convex polygon.
-
-
Constructor Detail
-
AbstractConvexPolygon3D
AbstractConvexPolygon3D(Plane plane)
Simple constructor.- Parameters:
plane
- the plane containing the convex polygon
-
-
Method Detail
-
getPlane
public Plane getPlane()
Get the plane containing this subset. This is equivalent toPlaneSubset.getHyperplane()
.- Specified by:
getPlane
in interfacePlaneSubset
- Returns:
- the plane containing this subset
- See Also:
PlaneSubset.getHyperplane()
-
isFull
public boolean isFull()
Return true if this instance contains all points in the hyperplane.This method always returns
false
.- Specified by:
isFull
in interfaceHyperplaneSubset<Vector3D>
- Returns:
- true if this instance contains all points in the hyperplane
-
isEmpty
public boolean isEmpty()
Return true if this instance does not contain any points.This method always returns
false
.- Specified by:
isEmpty
in interfaceHyperplaneSubset<Vector3D>
- Returns:
- true if this instance does not contain any points
-
getSize
public double getSize()
Get the size of the instance.
-
getCentroid
public Vector3D getCentroid()
Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique. A centroid will not exist for empty or infinite subsets.The centroid of a geometric object is defined as the mean position of all points in the object, including interior points, vertices, and other points lying on the boundary. If a physical object has a uniform density, then its center of mass is the same as its geometric centroid.
- Specified by:
getCentroid
in interfaceHyperplaneSubset<Vector3D>
- Returns:
- the centroid of the hyperplane subset or null if no unique centroid exists
- See Also:
- Centroid
-
getBounds
public Bounds3D getBounds()
Get aBounds3D
object defining an axis-aligned bounding box containing all vertices for this subset. Null is returned if the subset is infinite or does not contain any vertices.- Specified by:
getBounds
in interfacePlaneSubset
- Returns:
- the bounding box for this instance or null if no valid bounds could be determined
-
classify
public RegionLocation classify(Vector3D pt)
Classify a point with respect to the subset region. The point is classified as follows:- Specified by:
classify
in interfaceHyperplaneSubset<Vector3D>
- Parameters:
pt
- the point to classify- Returns:
- classification of the point with respect to the hyperplane and subspace region
-
closest
public Vector3D closest(Vector3D pt)
Return the closest point to the argument that is contained in the subset (ie, not classified asoutside
), or null if no such point exists.- Specified by:
closest
in interfaceHyperplaneSubset<Vector3D>
- Parameters:
pt
- the reference point- Returns:
- the closest point to the reference point that is contained in the subset, or null if no such point exists
-
getEmbedded
public PlaneConvexSubset.Embedded getEmbedded()
Return an object containing the plane subset as an embedded 2D subspace region.- Specified by:
getEmbedded
in interfacePlaneConvexSubset
- Specified by:
getEmbedded
in interfacePlaneSubset
- Returns:
- an object containing the plane subset as an embedded 2D subspace region
-
split
public Split<PlaneConvexSubset> split(Hyperplane<Vector3D> splitter)
Split this instance with the given hyperplane.- Specified by:
split
in interfaceHyperplaneConvexSubset<Vector3D>
- Specified by:
split
in interfacePlaneConvexSubset
- Specified by:
split
in interfaceSplittable<Vector3D,HyperplaneSubset<Vector3D>>
- Parameters:
splitter
- the hyperplane to split this object with.- Returns:
- result of the split operation
-
buildPolygonSplitVertexList
private java.util.List<Vector3D> buildPolygonSplitVertexList(int enterIdx, Vector3D newEnterPt, int exitIdx, Vector3D newExitPt, java.util.List<? extends Vector3D> vertices)
Internal method for building a vertex list for one side of a split result. The method is designed to make the fewest allocations possible.- Parameters:
enterIdx
- the index of the vertex fromvertices
immediately before the polygon transitioned to being fully entered into this side of the split result. If no point fromvertices
lay directly on the splitting plane while entering this side and a new vertex had to be computed for the split result, then this index will be the last vertex on the opposite side of the split. If a vertex did lie directly on the splitting plane, then this index will point to that vertex.newEnterPt
- the newly-computed point to be added as the first vertex in the split result; may be null if no such point existsexitIdx
- the index of the vertex fromvertices
immediately before the polygon transitioned to being fully exited from this side of the split result. If no point fromvertices
lay directly on the splitting plane while exiting this side and a new vertex had to be computed for the split result, then this index will be the last vertex on the this side of the split. If a vertex did lie directly on the splitting plane, then this index will point to that vertex.newExitPt
- the newly-computed point to be added as the last vertex in the split result; may be null if no such point existsvertices
- the original list of vertices that this split result originated from; this list is not modified by this operation- Returns:
- the list of vertices for the split result
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-