Class Parallelepiped

    • 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 points a and b 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 of b)
        b - second corner point in the prism (opposite of a)
        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 cube
        precision - 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 new Parallelepiped.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,
                                                    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 index
        b - second vertex index
        c - third vertex index
        d - fourth vertex index
        vertices - list of vertices for the parallelepiped
        reverse - if true, reverse the orientation of the face
        precision - 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 vertex
        b - second vertex
        precision - 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