Class BoundingBoxDouble

java.lang.Object
gaiasky.util.math.BoundingBoxDouble
All Implemented Interfaces:
Serializable

public class BoundingBoxDouble extends Object implements Serializable
See Also:
  • Field Details

  • Constructor Details

    • BoundingBoxDouble

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

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

      public BoundingBoxDouble(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 Details

    • getCenter

      @Deprecated public Vector3d getCenter()
      Deprecated.
      Returns:
      the center of the bounding box
    • 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
    • getCorner000

      public Vector3d getCorner000(Vector3d out)
    • getCorner001

      public Vector3d getCorner001(Vector3d out)
    • getCorner010

      public Vector3d getCorner010(Vector3d out)
    • getCorner011

      public Vector3d getCorner011(Vector3d out)
    • getCorner100

      public Vector3d getCorner100(Vector3d out)
    • getCorner101

      public Vector3d getCorner101(Vector3d out)
    • getCorner110

      public Vector3d getCorner110(Vector3d out)
    • getCorner111

      public Vector3d getCorner111(Vector3d out)
    • 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()
    • getGreatestDim

      public double getGreatestDim()
    • getMin

      @Deprecated public Vector3d getMin()
      Deprecated.
      Use getMin(Vector3d) instead.
      Returns:
      The minimum vector
    • getMin

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

      @Deprecated public Vector3d getMax()
      Deprecated.
      Use getMax(Vector3d) instead
      Returns:
      The maximum vector
    • 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 BoundingBoxDouble set(BoundingBoxDouble 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 BoundingBoxDouble 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 BoundingBoxDouble 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 BoundingBoxDouble set(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 BoundingBoxDouble inf()
      Sets the minimum and maximum vector to positive and negative infinity.
      Returns:
      This bounding box for chaining.
    • ext

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

      public BoundingBoxDouble 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 BoundingBoxDouble ext(BoundingBoxDouble 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 BoundingBoxDouble ext(BoundingBoxDouble 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 BoundingBoxDouble 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(BoundingBoxDouble 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(BoundingBoxDouble 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 String toString()
      Overrides:
      toString in class Object
    • ext

      public BoundingBoxDouble 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.