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 for ConvexPolygon3D implementations.
  • Field Details

    • plane

      private final Plane plane
      Plane containing the convex polygon.
  • Constructor Details

    • AbstractConvexPolygon3D

      AbstractConvexPolygon3D(Plane plane)
      Simple constructor.
      Parameters:
      plane - the plane containing the convex polygon
  • Method Details

    • getPlane

      public Plane getPlane()
      Get the plane containing this subset. This is equivalent to PlaneSubset.getHyperplane().
      Specified by:
      getPlane in interface PlaneSubset
      Returns:
      the plane containing this subset
      See Also:
    • isFull

      public boolean isFull()
      Return true if this instance contains all points in the hyperplane.

      This method always returns false.

      Specified by:
      isFull in interface HyperplaneSubset<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 interface HyperplaneSubset<Vector3D>
      Returns:
      true if this instance does not contain any points
    • getSize

      public double getSize()
      Get the size of the instance.
      Specified by:
      getSize in interface Sized
      Returns:
      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 interface HyperplaneSubset<Vector3D>
      Returns:
      the centroid of the hyperplane subset or null if no unique centroid exists
      See Also:
    • getBounds

      public Bounds3D getBounds()
      Get a Bounds3D 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 interface PlaneSubset
      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:
      • INSIDE - The point lies on the hyperplane and inside of the subset region.
      • BOUNDARY - The point lies on the hyperplane and is on the boundary of the subset region.
      • OUTSIDE - The point does not lie on the hyperplane or it does lie on the hyperplane but is outside of the subset region.
      Specified by:
      classify in interface HyperplaneSubset<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 as outside), or null if no such point exists.
      Specified by:
      closest in interface HyperplaneSubset<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 interface PlaneConvexSubset
      Specified by:
      getEmbedded in interface PlaneSubset
      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 interface HyperplaneConvexSubset<Vector3D>
      Specified by:
      split in interface PlaneConvexSubset
      Specified by:
      split in interface Splittable<Vector3D,HyperplaneSubset<Vector3D>>
      Parameters:
      splitter - the hyperplane to split this object with.
      Returns:
      result of the split operation
    • buildPolygonSplitVertexList

      private List<Vector3D> buildPolygonSplitVertexList(int enterIdx, Vector3D newEnterPt, int exitIdx, Vector3D newExitPt, 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 from vertices immediately before the polygon transitioned to being fully entered into this side of the split result. If no point from vertices 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 exists
      exitIdx - the index of the vertex from vertices immediately before the polygon transitioned to being fully exited from this side of the split result. If no point from vertices 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 exists
      vertices - 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 String toString()
      Overrides:
      toString in class Object