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
public final class Parallelepiped extends ConvexVolume
Class representing parallelepipeds, i.e. 3 dimensional figures formed by six parallelograms. For example, cubes and rectangular prisms are parallelepipeds.- See Also:
- Parallelepiped
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParallelepiped.BuilderClass designed to aid construction ofParallelepipedinstances.-
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 java.util.List<Vector3D>UNIT_CUBE_VERTICESVertices defining a cube with sides of length 1 centered at the origin.
-
Constructor Summary
Constructors Modifier Constructor Description privateParallelepiped(java.util.List<PlaneConvexSubset> boundaries)Simple constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ParallelepipedaxisAligned(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.Builderbuilder(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)Return a newParallelepiped.Builderinstance to use for constructing parallelepipeds.private static PlaneConvexSubsetcreateFace(int a, int b, int c, int d, java.util.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 voidensureNonZeroSideLength(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 ParallelepipedfromTransformedUnitCube(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 ParallelepipedunitCube(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 Detail
-
UNIT_CUBE_VERTICES
private static final java.util.List<Vector3D> UNIT_CUBE_VERTICES
Vertices defining a cube with sides of length 1 centered at the origin.
-
-
Constructor Detail
-
Parallelepiped
private Parallelepiped(java.util.List<PlaneConvexSubset> boundaries)
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 Detail
-
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 pointsaandbare 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:
java.lang.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:
java.lang.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.Builderinstance to use for constructing parallelepipeds.- Parameters:
precision- precision context used to create boundaries- Returns:
- a new
Parallelepiped.Builderinstance
-
createFace
private static PlaneConvexSubset createFace(int a, int b, int c, int d, java.util.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:
java.lang.IllegalArgumentException- if the given points are equivalent according to the precision context
-
-