Package gaiasky.util.math
Class BoundingBoxd
- java.lang.Object
-
- gaiasky.util.math.BoundingBoxd
-
- All Implemented Interfaces:
java.io.Serializable
public class BoundingBoxd extends java.lang.Object implements java.io.SerializableEncapsulates 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 Summary
Constructors Constructor Description BoundingBoxd()Constructs a new bounding box with the minimum and maximum vector set to zeros.BoundingBoxd(BoundingBoxd bounds)Constructs a new bounding box from the given bounding box.BoundingBoxd(Vector3d minimum, Vector3d maximum)Constructs the new bounding box using the given minimum and maximum vector.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BoundingBoxdclr()Sets the minimum and maximum vector to zeros.booleancontains(double x, double y, double z)Returns whether the given position [xyz] is contained in this bounding box.booleancontains(BoundingBoxd b)Returns whether the given bounding box is contained in this bounding box.booleancontains(Vector3d v)Returns whether the given vector is contained in this bounding box.BoundingBoxdext(double x, double y, double z)Extends the bounding box by the given vector.BoundingBoxdext(BoundingBoxd a_bounds)Extends this bounding box by the given bounding box.BoundingBoxdext(BoundingBoxd bounds, Matrix4d transform)Extends this bounding box by the given transformed bounding box.BoundingBoxdext(Vector3d point)Extends the bounding box to incorporate the givenVector3d.Vector3dgetCenter()Deprecated.Vector3dgetCenter(Vector3d out)doublegetCenterX()doublegetCenterY()doublegetCenterZ()Vector3dgetCorner000(Vector3d out)Vector3dgetCorner001(Vector3d out)Vector3dgetCorner010(Vector3d out)Vector3dgetCorner011(Vector3d out)Vector3dgetCorner100(Vector3d out)Vector3dgetCorner101(Vector3d out)Vector3dgetCorner110(Vector3d out)Vector3dgetCorner111(Vector3d out)Vector3d[]getCorners()Deprecated.Use the getCornerXYZ methods insteaddoublegetDepth()Vector3dgetDimensions()Deprecated.UsegetDimensions(Vector3d)insteadVector3dgetDimensions(Vector3d out)doublegetHeight()Vector3dgetMax()Deprecated.UsegetMax(Vector3d)insteadVector3dgetMax(Vector3d out)Vector3dgetMin()Deprecated.UsegetMin(Vector3d)instead.Vector3dgetMin(Vector3d out)doublegetVolume()doublegetWidth()BoundingBoxdinf()Sets the minimum and maximum vector to positive and negative infinity.booleanintersects(BoundingBoxd b)Returns whether the given bounding box is intersecting this bounding box (at least one point in).booleanisValid()Returns whether this bounding box is valid.BoundingBoxdmul(Matrix4d transform)Multiplies the bounding box by the given matrix.com.badlogic.gdx.math.collision.BoundingBoxput(com.badlogic.gdx.math.collision.BoundingBox bounds)BoundingBoxdset(BoundingBoxd bounds)Sets the given bounding box.BoundingBoxdset(Vector3d[] points)Sets the bounding box minimum and maximum vector from the given points.BoundingBoxdset(Vector3d minimum, Vector3d maximum)Sets the given minimum and maximum vector.BoundingBoxdset(java.util.List<Vector3d> points)Sets the bounding box minimum and maximum vector from the given points.java.lang.StringtoString()protected voidupdateCorners()Deprecated.
-
-
-
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
-
-
Method Detail
-
getCenter
@Deprecated public Vector3d getCenter()
Deprecated.- Returns:
- the center of the bounding box
-
getCenter
public Vector3d getCenter(Vector3d out)
- Parameters:
out- TheVector3dto 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.UsegetDimensions(Vector3d)instead- Returns:
- The dimensions of this bounding box on all three axis
-
getDimensions
public Vector3d getDimensions(Vector3d out)
- Parameters:
out- TheVector3dto 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
@Deprecated public Vector3d getMin()
Deprecated.UsegetMin(Vector3d)instead.- Returns:
- The minimum vector
-
getMin
public Vector3d getMin(Vector3d out)
- Parameters:
out- TheVector3dto receive the minimum values.- Returns:
- The vector specified with the out argument
-
getMax
@Deprecated public Vector3d getMax()
Deprecated.UsegetMax(Vector3d)instead- Returns:
- The maximum vector
-
getMax
public Vector3d getMax(Vector3d out)
- Parameters:
out- TheVector3dto 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 vectormaximum- 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 givenVector3d.- 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:
- 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 boxtransform- 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 componenty- The y componentz- The z component- Returns:
- Whether it is contained in this box
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
ext
public BoundingBoxd ext(double x, double y, double z)
Extends the bounding box by the given vector.- Parameters:
x- The x-coordinatey- The y-coordinatez- The z-coordinate- Returns:
- This bounding box for chaining.
-
-