Class ConvexVolume
- java.lang.Object
-
- org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion<Vector3D,PlaneConvexSubset>
-
- org.apache.commons.geometry.euclidean.threed.ConvexVolume
-
- All Implemented Interfaces:
BoundarySource<PlaneConvexSubset>
,HyperplaneBoundedRegion<Vector3D>
,Splittable<Vector3D,HyperplaneBoundedRegion<Vector3D>>
,Region<Vector3D>
,Sized
,BoundarySource3D
,Linecastable3D
- Direct Known Subclasses:
Parallelepiped
public class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Vector3D,PlaneConvexSubset> implements BoundarySource3D
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion
AbstractConvexHyperplaneBoundedRegion.ConvexRegionBoundaryBuilder<P extends Point<P>,S extends HyperplaneConvexSubset<P>>
-
-
Field Summary
Fields Modifier and Type Field Description private static ConvexVolume
FULL
Instance representing the full 3D volume.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConvexVolume(java.util.List<PlaneConvexSubset> boundaries)
Simple constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.stream.Stream<PlaneConvexSubset>
boundaryStream()
Return a stream containing the boundaries for this instance.static ConvexVolume
fromBounds(java.lang.Iterable<? extends Plane> boundingPlanes)
Create a convex volume formed by the intersection of the negative half-spaces of the given bounding planes.static ConvexVolume
fromBounds(Plane... planes)
Create a convex volume formed by the intersection of the negative half-spaces of the given bounding planes.static ConvexVolume
full()
Return an instance representing the full 3D volume.Vector3D
getCentroid()
Get the centroid, or geometric center, of the region or null if no centroid exists or one exists but is not unique.double
getSize()
Get the size of the instance.Split<ConvexVolume>
split(Hyperplane<Vector3D> splitter)
Split this instance with the given hyperplane.RegionBSPTree3D
toTree()
Return a BSP tree constructed from the boundaries contained in this instance.ConvexVolume
transform(Transform<Vector3D> transform)
Return a new instance transformed by the argument.PlaneConvexSubset
trim(HyperplaneConvexSubset<Vector3D> convexSubset)
Trim the given hyperplane subset to the portion contained inside this instance.-
Methods inherited from class org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion
classify, getBoundaries, getBoundarySize, isEmpty, isFull, project, splitInternal, swapsInsideOutside, toString, transformInternal
-
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.BoundarySource3D
getBounds, linecast, linecastFirst, toList, toTriangleMesh, triangleStream
-
Methods inherited from interface org.apache.commons.geometry.euclidean.threed.line.Linecastable3D
linecast, linecastFirst
-
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
-
-
-
Field Detail
-
FULL
private static final ConvexVolume FULL
Instance representing the full 3D volume.
-
-
Constructor Detail
-
ConvexVolume
protected ConvexVolume(java.util.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 Detail
-
boundaryStream
public java.util.stream.Stream<PlaneConvexSubset> boundaryStream()
Return a stream containing the boundaries for this instance.- Specified by:
boundaryStream
in interfaceBoundarySource<PlaneConvexSubset>
- Returns:
- a stream containing the boundaries for this instance
-
getSize
public double getSize()
Get 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 interfaceRegion<Vector3D>
- Returns:
- the centroid of the region or null if no unique centroid exists
- See Also:
- Centroid
-
split
public Split<ConvexVolume> split(Hyperplane<Vector3D> splitter)
Split this instance with the given hyperplane.- Specified by:
split
in interfaceSplittable<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 asRegionBSPTree3D.PartitionedRegionBuilder3D
.- Specified by:
toTree
in interfaceBoundarySource3D
- Returns:
- a BSP tree constructed from the boundaries in this instance
- See Also:
RegionBSPTree3D.partitionedRegionBuilder()
-
trim
public PlaneConvexSubset trim(HyperplaneConvexSubset<Vector3D> convexSubset)
Trim the given hyperplane subset to the portion contained inside this instance.- Overrides:
trim
in classAbstractConvexHyperplaneBoundedRegion<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:
java.lang.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(java.lang.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:
java.lang.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.
-
-