Class BoundingBoxd

  • All Implemented Interfaces:
    java.io.Serializable

    public class BoundingBoxd
    extends java.lang.Object
    implements java.io.Serializable
    Encapsulates an axis aligned bounding box represented by a minimum and a maximum Vector. Additionally you can query for the bounding box's center, dimensions and corner points.
    See Also:
    Serialized Form
    • Constructor Detail

      • BoundingBoxd

        public BoundingBoxd()
        Constructs a new bounding box with the minimum and maximum vector set to zeros.
      • BoundingBoxd

        public BoundingBoxd​(BoundingBoxd bounds)
        Constructs a new bounding box from the given bounding box.
        Parameters:
        bounds - The bounding box to copy
      • BoundingBoxd

        public BoundingBoxd​(Vector3d minimum,
                            Vector3d maximum)
        Constructs the new bounding box using the given minimum and maximum vector.
        Parameters:
        minimum - The minimum vector
        maximum - The maximum vector
    • Method Detail

      • getCenter

        public Vector3d getCenter​(Vector3d out)
        Parameters:
        out - The Vector3d to receive the center of the bounding box.
        Returns:
        The vector specified with the out argument.
      • getCenterX

        public double getCenterX()
      • getCenterY

        public double getCenterY()
      • getCenterZ

        public double getCenterZ()
      • updateCorners

        @Deprecated
        protected void updateCorners()
        Deprecated.
      • getCorners

        @Deprecated
        public Vector3d[] getCorners()
        Deprecated.
        Use the getCornerXYZ methods instead
        Returns:
        the corners of this bounding box
      • getDimensions

        @Deprecated
        public Vector3d getDimensions()
        Deprecated.
        Returns:
        The dimensions of this bounding box on all three axis
      • getDimensions

        public Vector3d getDimensions​(Vector3d out)
        Parameters:
        out - The Vector3d to receive the dimensions of this bounding box on all three axis.
        Returns:
        The vector specified with the out argument
      • getVolume

        public double getVolume()
      • getWidth

        public double getWidth()
      • getHeight

        public double getHeight()
      • getDepth

        public double getDepth()
      • getMin

        public Vector3d getMin​(Vector3d out)
        Parameters:
        out - The Vector3d to receive the minimum values.
        Returns:
        The vector specified with the out argument
      • getMax

        public Vector3d getMax​(Vector3d out)
        Parameters:
        out - The Vector3d to receive the maximum values.
        Returns:
        The vector specified with the out argument
      • set

        public BoundingBoxd set​(BoundingBoxd bounds)
        Sets the given bounding box.
        Parameters:
        bounds - The bounds.
        Returns:
        This bounding box for chaining.
      • put

        public com.badlogic.gdx.math.collision.BoundingBox put​(com.badlogic.gdx.math.collision.BoundingBox bounds)
      • set

        public BoundingBoxd set​(Vector3d minimum,
                                Vector3d maximum)
        Sets the given minimum and maximum vector.
        Parameters:
        minimum - The minimum vector
        maximum - The maximum vector
        Returns:
        This bounding box for chaining.
      • set

        public BoundingBoxd set​(Vector3d[] points)
        Sets the bounding box minimum and maximum vector from the given points.
        Parameters:
        points - The points.
        Returns:
        This bounding box for chaining.
      • set

        public BoundingBoxd set​(java.util.List<Vector3d> points)
        Sets the bounding box minimum and maximum vector from the given points.
        Parameters:
        points - The points.
        Returns:
        This bounding box for chaining.
      • inf

        public BoundingBoxd inf()
        Sets the minimum and maximum vector to positive and negative infinity.
        Returns:
        This bounding box for chaining.
      • ext

        public BoundingBoxd ext​(Vector3d point)
        Extends the bounding box to incorporate the given Vector3d.
        Parameters:
        point - The vector
        Returns:
        This bounding box for chaining.
      • clr

        public BoundingBoxd clr()
        Sets the minimum and maximum vector to zeros.
        Returns:
        This bounding box for chaining.
      • isValid

        public boolean isValid()
        Returns whether this bounding box is valid. This means that max is greater than min.
        Returns:
        True in case the bounding box is valid, false otherwise
      • ext

        public BoundingBoxd ext​(BoundingBoxd a_bounds)
        Extends this bounding box by the given bounding box.
        Parameters:
        a_bounds - The bounding box
        Returns:
        This bounding box for chaining.
      • ext

        public BoundingBoxd ext​(BoundingBoxd bounds,
                                Matrix4d transform)
        Extends this bounding box by the given transformed bounding box.
        Parameters:
        bounds - The bounding box
        transform - The transformation matrix to apply to bounds, before using it to extend this bounding box.
        Returns:
        This bounding box for chaining.
      • mul

        public BoundingBoxd mul​(Matrix4d transform)
        Multiplies the bounding box by the given matrix. This is achieved by multiplying the 8 corner points and then calculating the minimum and maximum vectors from the transformed points.
        Parameters:
        transform - The matrix
        Returns:
        This bounding box for chaining.
      • contains

        public boolean contains​(BoundingBoxd b)
        Returns whether the given bounding box is contained in this bounding box.
        Parameters:
        b - The bounding box
        Returns:
        Whether the given bounding box is contained
      • intersects

        public boolean intersects​(BoundingBoxd b)
        Returns whether the given bounding box is intersecting this bounding box (at least one point in).
        Parameters:
        b - The bounding box
        Returns:
        Whether the given bounding box is intersected
      • contains

        public boolean contains​(Vector3d v)
        Returns whether the given vector is contained in this bounding box.
        Parameters:
        v - The vector
        Returns:
        Whether the vector is contained or not.
      • contains

        public boolean contains​(double x,
                                double y,
                                double z)
        Returns whether the given position [xyz] is contained in this bounding box.
        Parameters:
        x - The x component
        y - The y component
        z - The z component
        Returns:
        Whether it is contained in this box
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • ext

        public BoundingBoxd ext​(double x,
                                double y,
                                double z)
        Extends the bounding box by the given vector.
        Parameters:
        x - The x-coordinate
        y - The y-coordinate
        z - The z-coordinate
        Returns:
        This bounding box for chaining.