Class Parallelepiped
java.lang.Object
org.apache.commons.geometry.core.partitioning.AbstractConvexHyperplaneBoundedRegion<Vector3D,PlaneConvexSubset>
org.apache.commons.geometry.euclidean.threed.ConvexVolume
org.apache.commons.geometry.euclidean.threed.shape.Parallelepiped
- All Implemented Interfaces:
BoundarySource<PlaneConvexSubset>
,HyperplaneBoundedRegion<Vector3D>
,Splittable<Vector3D,
,HyperplaneBoundedRegion<Vector3D>> Region<Vector3D>
,Sized
,BoundarySource3D
,Linecastable3D
Class representing parallelepipeds, i.e. 3 dimensional figures formed by six
parallelograms. For example, cubes and rectangular prisms are parallelepipeds.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Class designed to aid construction ofParallelepiped
instances.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
FieldsModifier and TypeFieldDescriptionVertices defining a cube with sides of length 1 centered at the origin. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Parallelepiped
(List<PlaneConvexSubset> boundaries) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic Parallelepiped
axisAligned
(Vector3D a, Vector3D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a new instance representing an axis-aligned parallelepiped, ie, a rectangular prism.static Parallelepiped.Builder
builder
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a newParallelepiped.Builder
instance to use for constructing parallelepipeds.private static PlaneConvexSubset
createFace
(int a, int b, int c, int d, List<? extends Vector3D> vertices, boolean reverse, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a single face of a parallelepiped using the indices of elements in the given vertex list.private static void
ensureNonZeroSideLength
(Vector3D a, Vector3D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Ensure that the given points defining one side of a parallelepiped face are separated by a non-zero distance, as determined by the precision context.static Parallelepiped
fromTransformedUnitCube
(Transform<Vector3D> transform, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance by transforming a unit cube centered at the origin.static Parallelepiped
unitCube
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance representing a unit cube centered at the origin.Methods inherited from class org.apache.commons.geometry.euclidean.threed.ConvexVolume
boundaryStream, fromBounds, fromBounds, full, getCentroid, getSize, split, toTree, transform, trim
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 Details
-
UNIT_CUBE_VERTICES
Vertices defining a cube with sides of length 1 centered at the origin.
-
-
Constructor Details
-
Parallelepiped
Simple constructor. Callers are responsible for ensuring that the given boundaries represent a parallelepiped. No validation is performed.- Parameters:
boundaries
- the boundaries of the parallelepiped; this must be a list with 6 elements
-
-
Method Details
-
unitCube
public static Parallelepiped unitCube(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance representing a unit cube centered at the origin. The vertices of this cube are:[ (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5) ]
- Parameters:
precision
- precision context used to construct boundaries- Returns:
- a new instance representing a unit cube centered at the origin
-
axisAligned
public static Parallelepiped axisAligned(Vector3D a, Vector3D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a new instance representing an axis-aligned parallelepiped, ie, a rectangular prism. The pointsa
andb
are taken to represent opposite corner points in the prism and may be specified in any order.- Parameters:
a
- first corner point in the prism (opposite ofb
)b
- second corner point in the prism (opposite ofa
)precision
- precision context used to construct boundaries- Returns:
- a new instance representing an axis-aligned rectangular prism
- Throws:
IllegalArgumentException
- if the width, height, or depth of the defined prism is zero as evaluated by the precision context.
-
fromTransformedUnitCube
public static Parallelepiped fromTransformedUnitCube(Transform<Vector3D> transform, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance by transforming a unit cube centered at the origin. The vertices of this input cube are:[ (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5) ]
- Parameters:
transform
- transform to apply to the vertices of the unit cubeprecision
- precision context used to construct boundaries- Returns:
- a new instance created by transforming the vertices of a unit cube centered at the origin
- Throws:
IllegalArgumentException
- if the width, height, or depth of the defined shape is zero as evaluated by the precision context.
-
builder
public static Parallelepiped.Builder builder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a newParallelepiped.Builder
instance to use for constructing parallelepipeds.- Parameters:
precision
- precision context used to create boundaries- Returns:
- a new
Parallelepiped.Builder
instance
-
createFace
private static PlaneConvexSubset createFace(int a, int b, int c, int d, List<? extends Vector3D> vertices, boolean reverse, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a single face of a parallelepiped using the indices of elements in the given vertex list.- Parameters:
a
- first vertex indexb
- second vertex indexc
- third vertex indexd
- fourth vertex indexvertices
- list of vertices for the parallelepipedreverse
- if true, reverse the orientation of the faceprecision
- precision context used to create the face- Returns:
- a parallelepiped face created from the indexed vertices
-
ensureNonZeroSideLength
private static void ensureNonZeroSideLength(Vector3D a, Vector3D b, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Ensure that the given points defining one side of a parallelepiped face are separated by a non-zero distance, as determined by the precision context.- Parameters:
a
- first vertexb
- second vertexprecision
- precision used to evaluate the distance between the two points- Throws:
IllegalArgumentException
- if the given points are equivalent according to the precision context
-