Class Bounds3D


  • public final class Bounds3D
    extends AbstractBounds<Vector3D,​Bounds3D>
    Class containing minimum and maximum points defining a 3D axis-aligned bounding box. Unless otherwise noted, floating point comparisons used in this class are strict, meaning that values are considered equal if and only if they match exactly.

    Instances of this class are guaranteed to be immutable.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Bounds3D.Builder
      Class used to construct Bounds3D instances.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Bounds3D​(Vector3D min, Vector3D max)
      Simple constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Bounds3D.Builder builder()
      Construct a new Bounds3D.Builder instance for creating bounds.
      boolean contains​(Vector3D pt)
      Return true if the given point is strictly within or on the boundary of the bounding box.
      boolean contains​(Vector3D pt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return true if the given point is within or on the boundary of the bounding box, using the given precision context for floating point comparisons.
      boolean equals​(java.lang.Object obj)
      static Bounds3D from​(java.lang.Iterable<Vector3D> points)
      Construct a new instance from the given points.
      static Bounds3D from​(Vector3D first, Vector3D... more)
      Construct a new instance from the given points.
      int hashCode()
      boolean hasSize​(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return true if the bounding box has non-zero size along each coordinate axis, as evaluated by the given precision context.
      Bounds3D intersection​(Bounds3D other)
      Return the intersection of this bounding box and the argument, or null if no intersection exists.
      boolean intersects​(Bounds3D other)
      Return true if any point on the interior or boundary of this instance is also considered to be on the interior or boundary of the argument.
      Parallelepiped toRegion​(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
      Return a hyperplane-bounded region containing the same points as this instance.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Bounds3D

        private Bounds3D​(Vector3D min,
                         Vector3D max)
        Simple constructor. Callers are responsible for ensuring the min is not greater than max.
        Parameters:
        min - minimum point
        max - maximum point
    • Method Detail

      • hasSize

        public boolean hasSize​(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
        Return true if the bounding box has non-zero size along each coordinate axis, as evaluated by the given precision context.
        Specified by:
        hasSize in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        precision - precision context used for floating point comparisons
        Returns:
        true if the bounding box has non-zero size along each coordinate axis
      • contains

        public boolean contains​(Vector3D pt)
        Return true if the given point is strictly within or on the boundary of the bounding box. In other words, true if returned if pt >= mint and pt <= maxt for each coordinate value t. Floating point comparisons are strict; values are considered equal only if they match exactly.
        Specified by:
        contains in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        pt - the point to check
        Returns:
        true if the given point is strictly within or on the boundary of the instance
        See Also:
        AbstractBounds.contains(EuclideanVector, Precision.DoubleEquivalence)
      • contains

        public boolean contains​(Vector3D pt,
                                org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
        Return true if the given point is within or on the boundary of the bounding box, using the given precision context for floating point comparisons. This is similar to AbstractBounds.contains(EuclideanVector) but allows points that may be strictly outside of the box due to floating point errors to be considered inside.
        Specified by:
        contains in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        pt - the point to check
        precision - precision context used to compare floating point values
        Returns:
        if the given point is within or on the boundary of the bounds, as determined by the given precision context
        See Also:
        AbstractBounds.contains(EuclideanVector, Precision.DoubleEquivalence)
      • intersects

        public boolean intersects​(Bounds3D other)
        Return true if any point on the interior or boundary of this instance is also considered to be on the interior or boundary of the argument. Specifically, true is returned if aMint <= bMaxt and aMaxt >= bMint for all coordinate values t, where a is the current instance and b is the argument. Floating point comparisons are strict; values are considered equal only if they match exactly.
        Specified by:
        intersects in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        other - bounding box to intersect with
        Returns:
        true if the bounds intersect
      • intersection

        public Bounds3D intersection​(Bounds3D other)
        Return the intersection of this bounding box and the argument, or null if no intersection exists. Floating point comparisons are strict; values are considered equal only if they match exactly. Note this this method may return bounding boxes with zero size in one or more coordinate axes.
        Specified by:
        intersection in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        other - bounding box to intersect with
        Returns:
        the intersection of this instance and the argument, or null if no such intersection exists
        See Also:
        AbstractBounds.intersects(AbstractBounds)
      • toRegion

        public Parallelepiped toRegion​(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
        Return a hyperplane-bounded region containing the same points as this instance.
        Specified by:
        toRegion in class AbstractBounds<Vector3D,​Bounds3D>
        Parameters:
        precision - precision context used for floating point comparisons in the returned region instance
        Returns:
        a hyperplane-bounded region containing the same points as this instance
        Throws:
        java.lang.IllegalArgumentException - if any dimension of the bounding box is zero as evaluated by the given precision context
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • from

        public static Bounds3D from​(Vector3D first,
                                    Vector3D... more)
        Construct a new instance from the given points.
        Parameters:
        first - first point
        more - additional points
        Returns:
        a new instance containing the min and max coordinates values from the input points
      • from

        public static Bounds3D from​(java.lang.Iterable<Vector3D> points)
        Construct a new instance from the given points.
        Parameters:
        points - input points
        Returns:
        a new instance containing the min and max coordinates values from the input points
      • builder

        public static Bounds3D.Builder builder()
        Construct a new Bounds3D.Builder instance for creating bounds.
        Returns:
        a new builder instance for creating bounds