Class EmbeddedTreePlaneSubset

java.lang.Object
org.apache.commons.geometry.euclidean.threed.EmbeddedTreePlaneSubset
All Implemented Interfaces:
Embedding<Vector3D,Vector2D>, HyperplaneSubset<Vector3D>, Splittable<Vector3D, HyperplaneSubset<Vector3D>>, RegionEmbedding<Vector3D,Vector2D>, Sized, PlaneSubset, PlaneSubset.Embedded

public final class EmbeddedTreePlaneSubset extends Object
Class representing an arbitrary subset of a plane using a RegionBSPTree2D. This class can represent convex, non-convex, finite, infinite, and empty regions.

This class is mutable and not thread safe.

  • Constructor Details

    • EmbeddedTreePlaneSubset

      Construct a new, empty plane subset for the given plane.
      Parameters:
      plane - plane containing the subset
    • EmbeddedTreePlaneSubset

      public EmbeddedTreePlaneSubset(EmbeddingPlane plane, boolean full)
      Construct a new subset for the given plane. If full is true, then the subset will cover the entire plane; otherwise, it will be empty.
      Parameters:
      plane - plane containing the subset
      full - if true, the subset will cover the entire space; otherwise it will be empty
    • EmbeddedTreePlaneSubset

      Construct a new instance from its defining plane and subspace region.
      Parameters:
      plane - plane containing the subset
      region - subspace region for the plane subset
  • Method Details

    • getEmbedded

      Return an object containing the plane subset as an embedded 2D subspace region.
      Returns:
      an object containing the plane subset as an embedded 2D subspace region
    • getSubspaceRegion

      Get the embedded subspace region.
      Returns:
      the embedded subspace region
    • toConvex

      Convert this instance into a list of convex child subsets representing the same region. Implementations are not required to return an optimal convex subdivision of the current instance. They are free to return whatever subdivision is readily available.
      Returns:
      a list of hyperplane convex subsets representing the same subspace region as this instance
    • toTriangles

      Return a list of triangles representing the same subset region as this instance. An IllegalStateException is thrown if the subset has infinite size and therefore cannot be converted to triangles. If the subset has zero size (is empty), an empty list is returned.
      Returns:
      a list of triangles representing the same subset region as this instance
    • 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.
      Returns:
      the bounding box for this instance or null if no valid bounds could be determined
    • split

      Split this instance with the given hyperplane.

      In all cases, the current instance is not modified. However, In order to avoid unnecessary copying, this method will use the current instance as the split value when the instance lies entirely on the plus or minus side of the splitter. For example, if this instance lies entirely on the minus side of the splitter, the plane subset returned by Split.getMinus() will be this instance. Similarly, Split.getPlus() will return the current instance if it lies entirely on the plus side. Callers need to make special note of this, since this class is mutable.

      Parameters:
      splitter - the hyperplane to split this object with.
      Returns:
      result of the split operation
    • transform

      Return a new hyperplane subset resulting from the application of the given transform. The current instance is not modified.
      Parameters:
      transform - the transform instance to apply
      Returns:
      new transformed hyperplane subset
    • add

      public void add(PlaneConvexSubset subset)
      Add a plane convex subset to this instance.
      Parameters:
      subset - plane convex subset to add
      Throws:
      IllegalArgumentException - if the given plane subset is not from a plane equivalent to this instance
    • add

      public void add(EmbeddedTreePlaneSubset subset)
      Add a plane subset to this instance.
      Parameters:
      subset - plane subset to add
      Throws:
      IllegalArgumentException - if the given plane subset is not from a plane equivalent to this instance
    • getPlane

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

      public EmbeddingPlane getHyperplane()
      Get the hyperplane containing this instance.
      Specified by:
      getHyperplane in interface HyperplaneSubset<Vector3D>
      Specified by:
      getHyperplane in interface PlaneSubset
      Returns:
      the hyperplane containing this instance
    • isFull

      public boolean isFull()
      Return true if this instance contains all points in the hyperplane.
      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.
      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:
    • toSpace

      public Vector3D toSpace(Vector2D pt)
      Transform a subspace point into a space point.
      Specified by:
      toSpace in interface Embedding<Vector3D,Vector2D>
      Parameters:
      pt - lower-dimension point of the subspace
      Returns:
      n-dimension point of the space corresponding to the specified subspace point
      See Also:
    • toSubspace

      public Vector2D toSubspace(Vector3D pt)
      Transform a space point into a subspace point.
      Specified by:
      toSubspace in interface Embedding<Vector3D,Vector2D>
      Parameters:
      pt - n-dimension point of the space
      Returns:
      lower-dimension point of the subspace corresponding to the specified space point
      See Also:
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getBoundsFromSubspace

      protected Bounds3D getBoundsFromSubspace(BoundarySource2D src)
      Compute 3D bounds from a subspace boundary source.
      Parameters:
      src - subspace boundary source
      Returns:
      3D bounds from the given embedded subspace boundary source or null if no valid bounds could be determined
    • intersection

      public Vector3D intersection(Line3D line)
      Get the unique intersection of this plane subset with the given line. Null is returned if no unique intersection point exists (ie, the line and plane are parallel or coincident) or the line does not intersect the plane subset.
      Specified by:
      intersection in interface PlaneSubset
      Parameters:
      line - line to intersect with this plane subset
      Returns:
      the unique intersection point between the line and this plane subset or null if no such point exists.
      See Also:
    • intersection

      public Vector3D intersection(LineConvexSubset3D lineSubset)
      Get the unique intersection of this plane subset with the given line subset. Null is returned if the underlying line and plane do not have a unique intersection point (ie, they are parallel or coincident) or the intersection point is unique but is not contained in both the line subset and plane subset.
      Specified by:
      intersection in interface PlaneSubset
      Parameters:
      lineSubset - line subset to intersect with
      Returns:
      the unique intersection point between this plane subset and the argument or null if no such point exists.
      See Also: