Class ConvexVolume

All Implemented Interfaces:
BoundarySource<PlaneConvexSubset>, HyperplaneBoundedRegion<Vector3D>, Splittable<Vector3D,HyperplaneBoundedRegion<Vector3D>>, Region<Vector3D>, Sized, BoundarySource3D, Linecastable3D
Direct Known Subclasses:
Parallelepiped

Class representing a finite or infinite convex volume in Euclidean 3D space. The boundaries of this area, if any, are composed of plane convex subsets.
  • Field Details

    • FULL

      private static final ConvexVolume FULL
      Instance representing the full 3D volume.
  • Constructor Details

    • ConvexVolume

      protected ConvexVolume(List<PlaneConvexSubset> boundaries)
      Simple constructor. Callers are responsible for ensuring that the given path represents the boundary of a convex area. No validation is performed.
      Parameters:
      boundaries - the boundaries of the convex area
  • Method Details

    • boundaryStream

      public Stream<PlaneConvexSubset> boundaryStream()
      Return a stream containing the boundaries for this instance.
      Specified by:
      boundaryStream in interface BoundarySource<PlaneConvexSubset>
      Returns:
      a stream containing the boundaries for this instance
    • 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 region or null if no centroid exists or one exists but is not unique. A centroid will not exist for empty or infinite regions.

      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 Region<Vector3D>
      Returns:
      the centroid of the region or null if no unique centroid exists
      See Also:
    • split

      public Split<ConvexVolume> split(Hyperplane<Vector3D> splitter)
      Split this instance with the given hyperplane.
      Specified by:
      split in interface Splittable<Vector3D,HyperplaneBoundedRegion<Vector3D>>
      Parameters:
      splitter - the hyperplane to split this object with.
      Returns:
      result of the split operation
    • toTree

      public RegionBSPTree3D toTree()
      Return a BSP tree constructed from the boundaries contained in this instance. This is a convenience method for quickly constructing BSP trees and may produce unbalanced trees with unacceptable performance characteristics when used with large numbers of boundaries. In these cases, alternate tree construction approaches should be used, such as RegionBSPTree3D.PartitionedRegionBuilder3D.
      Specified by:
      toTree in interface BoundarySource3D
      Returns:
      a BSP tree constructed from the boundaries in this instance
      See Also:
    • trim

      public PlaneConvexSubset trim(HyperplaneConvexSubset<Vector3D> convexSubset)
      Trim the given hyperplane subset to the portion contained inside this instance.
      Overrides:
      trim in class AbstractConvexHyperplaneBoundedRegion<Vector3D,PlaneConvexSubset>
      Parameters:
      convexSubset - hyperplane subset to trim. Null is returned if the subset does not intersect the instance.
      Returns:
      portion of the argument that lies entirely inside the region represented by this instance, or null if it does not intersect.
    • transform

      public ConvexVolume transform(Transform<Vector3D> transform)
      Return a new instance transformed by the argument.
      Parameters:
      transform - transform to apply
      Returns:
      a new instance transformed by the argument
    • full

      public static ConvexVolume full()
      Return an instance representing the full 3D volume.
      Returns:
      an instance representing the full 3D volume.
    • fromBounds

      public static ConvexVolume fromBounds(Plane... planes)
      Create a convex volume formed by the intersection of the negative half-spaces of the given bounding planes. The returned instance represents the volume that is on the minus side of all of the given plane. Note that this method does not support volumes of zero size (ie, infinitely thin volumes or points.)
      Parameters:
      planes - planes used to define the convex area
      Returns:
      a new convex volume instance representing the volume on the minus side of all of the bounding plane or an instance representing the full space if the collection is empty
      Throws:
      IllegalArgumentException - if the given set of bounding planes do not form a convex volume, meaning that there is no region that is on the minus side of all of the bounding planes.
    • fromBounds

      public static ConvexVolume fromBounds(Iterable<? extends Plane> boundingPlanes)
      Create a convex volume formed by the intersection of the negative half-spaces of the given bounding planes. The returned instance represents the volume that is on the minus side of all of the given plane. Note that this method does not support volumes of zero size (ie, infinitely thin volumes or points.)
      Parameters:
      boundingPlanes - planes used to define the convex area
      Returns:
      a new convex volume instance representing the volume on the minus side of all of the bounding plane or an instance representing the full space if the collection is empty
      Throws:
      IllegalArgumentException - if the given set of bounding planes do not form a convex volume, meaning that there is no region that is on the minus side of all of the bounding planes.