public class BoundingBox
extends java.lang.Object
A bounding box may be empty. An empty box contains no points. A non-empty box contains at least one point. Some attributes, such as the box minimum and maximum points, center, and radius, are defined only for boxes that are not empty.
A bounding box may be infinite. An infinite box contains all points. Its minimum and maximum points are at Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY, respectively, and its center is undefined.
Constructor and Description |
---|
BoundingBox()
Constructs an empty bounding box.
|
BoundingBox(BoundingBox bb)
Constructs a copy of the specified bounding box.
|
BoundingBox(double xmin,
double ymin,
double zmin,
double xmax,
double ymax,
double zmax)
Constructs a bounding box with specified bounds.
|
BoundingBox(float[] xyz)
Constructs a bounding box for points with specified coordinates.
|
BoundingBox(float[] x,
float[] y,
float[] z)
Constructs a bounding box for points with specified coordinates.
|
BoundingBox(Point3 p)
Constructs the smallest bounding box that contains one point.
|
BoundingBox(Point3 p,
Point3 q)
Constructs the smallest bounding box that contains two points.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(BoundingBox bb)
Determines whether this box contains the specified bounding box.
|
boolean |
contains(double x,
double y,
double z)
Determines whether this box contains the point with specified coordinates.
|
boolean |
contains(Point3 p)
Determines whether this box contains the specified point.
|
static BoundingBox |
empty()
Returns a new empty bounding box.
|
void |
expandBy(BoundingBox bb)
Expands this box to include the specified bounding box.
|
void |
expandBy(BoundingSphere bs)
Expands this box to include the specified bounding sphere.
|
void |
expandBy(double x,
double y,
double z)
Expands this box to include the point with specified coordinates.
|
void |
expandBy(float[] xyz)
Expands this box to include the points with specified coordinates.
|
void |
expandBy(float[] x,
float[] y,
float[] z)
Expands this box to include the points with specified coordinates.
|
void |
expandBy(Point3 p)
Expands this box to include the specified point.
|
Point3 |
getCenter()
Gets the point at the center of this box.
|
Point3 |
getCorner(int index)
Gets the point at a specified corner of this box.
|
Point3 |
getMax()
Gets the point in this box with maximum coordinates.
|
Point3 |
getMin()
Gets the point in this box with minimum coordinates.
|
double |
getRadius()
Gets the box radius, the distance from the center to any corner.
|
double |
getRadiusSquared()
Gets the box radius-squared.
|
static BoundingBox |
infinite()
Returns a new infinite bounding box.
|
boolean |
intersects(BoundingBox bb)
Determines whether this box intersects the specified bounding box.
|
boolean |
isEmpty()
Determines whether this box is empty.
|
boolean |
isInfinite()
Determines whether this box is infinite.
|
java.lang.String |
toString() |
public BoundingBox()
public BoundingBox(Point3 p)
p
- a point.public BoundingBox(Point3 p, Point3 q)
p
- a point.q
- a point.public BoundingBox(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
xmin
- the minimum x coordinate.ymin
- the minimum y coordinate.zmin
- the minimum z coordinate.xmax
- the maximum x coordinate.ymax
- the maximum y coordinate.zmax
- the maximum z coordinate.public BoundingBox(float[] xyz)
xyz
- array of packed (x,y,z) coordinates.public BoundingBox(float[] x, float[] y, float[] z)
x
- array of x coordinates.y
- array of y coordinates.z
- array of z coordinates.public BoundingBox(BoundingBox bb)
bb
- the bounding box.public boolean isEmpty()
public boolean isInfinite()
public Point3 getMin()
public Point3 getMax()
public Point3 getCenter()
public double getRadius()
public double getRadiusSquared()
public Point3 getCorner(int index)
index
- the corner index.public void expandBy(Point3 p)
p
- the point.public void expandBy(double x, double y, double z)
x
- the point x coordinate.y
- the point y coordinate.z
- the point z coordinate.public void expandBy(float[] xyz)
xyz
- array of packed (x,y,z) coordinates.public void expandBy(float[] x, float[] y, float[] z)
x
- array of x coordinates.y
- array of y coordinates.z
- array of z coordinates.public void expandBy(BoundingBox bb)
bb
- the bounding box.public void expandBy(BoundingSphere bs)
bs
- the bounding sphere.public boolean contains(double x, double y, double z)
x
- the point x coordinate.y
- the point y coordinate.z
- the point z coordinate.public boolean contains(Point3 p)
p
- the point.public boolean contains(BoundingBox bb)
bb
- the bounding box.public boolean intersects(BoundingBox bb)
bb
- the bounding box.public static BoundingBox empty()
public static BoundingBox infinite()
public java.lang.String toString()
toString
in class java.lang.Object