Package gaia.cu9.ari.gaiaorbit.util.math
Class BoundingBoxd
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.util.math.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 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 BoundingBoxd
clr()
Sets the minimum and maximum vector to zeros.boolean
contains(double x, double y, double z)
Returns whether the given position [xyz] is contained in this bounding box.boolean
contains(BoundingBoxd b)
Returns whether the given bounding box is contained in this bounding box.boolean
contains(Vector3d v)
Returns whether the given vector is contained in this bounding box.BoundingBoxd
ext(double x, double y, double z)
Extends the bounding box by the given vector.BoundingBoxd
ext(BoundingBoxd a_bounds)
Extends this bounding box by the given bounding box.BoundingBoxd
ext(BoundingBoxd bounds, Matrix4d transform)
Extends this bounding box by the given transformed bounding box.BoundingBoxd
ext(Vector3d point)
Extends the bounding box to incorporate the givenVector3d
.Vector3d
getCenter()
Deprecated.Vector3d
getCenter(Vector3d out)
double
getCenterX()
double
getCenterY()
double
getCenterZ()
Vector3d
getCorner000(Vector3d out)
Vector3d
getCorner001(Vector3d out)
Vector3d
getCorner010(Vector3d out)
Vector3d
getCorner011(Vector3d out)
Vector3d
getCorner100(Vector3d out)
Vector3d
getCorner101(Vector3d out)
Vector3d
getCorner110(Vector3d out)
Vector3d
getCorner111(Vector3d out)
Vector3d[]
getCorners()
Deprecated.Use the getCornerXYZ methods insteaddouble
getDepth()
Vector3d
getDimensions()
Deprecated.UsegetDimensions(Vector3d)
insteadVector3d
getDimensions(Vector3d out)
double
getHeight()
Vector3d
getMax()
Deprecated.UsegetMax(Vector3d)
insteadVector3d
getMax(Vector3d out)
Vector3d
getMin()
Deprecated.UsegetMin(Vector3d)
instead.Vector3d
getMin(Vector3d out)
double
getVolume()
double
getWidth()
BoundingBoxd
inf()
Sets the minimum and maximum vector to positive and negative infinity.boolean
intersects(BoundingBoxd b)
Returns whether the given bounding box is intersecting this bounding box (at least one point in).boolean
isValid()
Returns whether this bounding box is valid.BoundingBoxd
mul(Matrix4d transform)
Multiplies the bounding box by the given matrix.com.badlogic.gdx.math.collision.BoundingBox
put(com.badlogic.gdx.math.collision.BoundingBox bounds)
BoundingBoxd
set(BoundingBoxd bounds)
Sets the given bounding box.BoundingBoxd
set(Vector3d[] points)
Sets the bounding box minimum and maximum vector from the given points.BoundingBoxd
set(Vector3d minimum, Vector3d maximum)
Sets the given minimum and maximum vector.BoundingBoxd
set(java.util.List<Vector3d> points)
Sets the bounding box minimum and maximum vector from the given points.java.lang.String
toString()
protected void
updateCorners()
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
- TheVector3d
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.UsegetDimensions(Vector3d)
instead- Returns:
- The dimensions of this bounding box on all three axis
-
getDimensions
public Vector3d getDimensions(Vector3d out)
- Parameters:
out
- TheVector3d
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
@Deprecated public Vector3d getMin()
Deprecated.UsegetMin(Vector3d)
instead.- Returns:
- The minimum vector
-
getMin
public Vector3d getMin(Vector3d out)
- Parameters:
out
- TheVector3d
to 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
- TheVector3d
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 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:
toString
in 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.
-
-