public class BoundingSphere
extends java.lang.Object
A bounding sphere may be empty. An empty sphere contains no points. A non-empty sphere contains at least one point. Some attributes, such as the sphere center and radius, are defined only for spheres that are not empty.
A bounding sphere may be infinite. An infinite sphere contains all points. Its radius is Double.POSITIVE_INFINITY, and its center is undefined.
Constructor and Description |
---|
BoundingSphere()
Constructs an empty bounding sphere.
|
BoundingSphere(BoundingBox bb)
Constructs a bounding sphere that contains the specified bounding box.
|
BoundingSphere(BoundingSphere bs)
Constructs a copy of the specified bounding sphere.
|
BoundingSphere(double x,
double y,
double z,
double r)
Constructs a bounding sphere with specified center and radius.
|
BoundingSphere(Point3 c,
double r)
Constructs a bounding sphere with specified center and radius.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x,
double y,
double z)
Determines whether this sphere contains a point with specified coordinates.
|
boolean |
contains(Point3 p)
Determines whether this sphere contains the specified point.
|
static BoundingSphere |
empty()
Returns a new empty bounding sphere.
|
void |
expandBy(BoundingBox bb)
Expands this sphere to include the specified bounding box.
|
void |
expandBy(BoundingSphere bs)
Expands this sphere to include the specified bounding sphere.
|
void |
expandBy(double x,
double y,
double z)
Expands this sphere to include the point with specified coordinates.
|
void |
expandBy(Point3 p)
Expands this sphere to include the specified point.
|
void |
expandRadiusBy(BoundingBox bb)
Expands this sphere to include the specified bounding box.
|
void |
expandRadiusBy(BoundingSphere bs)
Expands this sphere to include the specified bounding sphere.
|
void |
expandRadiusBy(double x,
double y,
double z)
Expands this sphere to include the point with specified coordinates.
|
void |
expandRadiusBy(Point3 p)
Expands this sphere to include the specified point.
|
Point3 |
getCenter()
Gets the sphere center.
|
double |
getRadius()
Gets the sphere radius.
|
double |
getRadiusSquared()
Gets the sphere radius-squared.
|
static BoundingSphere |
infinite()
Returns a new infinite bounding sphere.
|
boolean |
isEmpty()
Determines whether this sphere is empty.
|
boolean |
isInfinite()
Determines whether this sphere is infinite.
|
java.lang.String |
toString() |
public BoundingSphere()
public BoundingSphere(double x, double y, double z, double r)
x
- the center x coordinate.y
- the center y coordinate.z
- the center z coordinate.r
- the radius; must be non-negative.public BoundingSphere(Point3 c, double r)
c
- the center.r
- the radius; must be non-negative.public BoundingSphere(BoundingBox bb)
bb
- the bounding box.public BoundingSphere(BoundingSphere bs)
bs
- the bounding sphere.public boolean isEmpty()
public boolean isInfinite()
public Point3 getCenter()
public double getRadius()
public double getRadiusSquared()
public void expandBy(double x, double y, double z)
x
- the x coordinate of the point.y
- the y coordinate of the point.z
- the z coordinate of the point.public void expandRadiusBy(double x, double y, double z)
x
- the x coordinate of the point.y
- the y coordinate of the point.z
- the z coordinate of the point.public void expandBy(Point3 p)
p
- the point.public void expandRadiusBy(Point3 p)
p
- the point.public void expandBy(BoundingSphere bs)
bs
- the bounding sphere.public void expandRadiusBy(BoundingSphere bs)
bs
- the bounding sphere.public void expandBy(BoundingBox bb)
bb
- the bounding box.public void expandRadiusBy(BoundingBox bb)
bb
- the bounding box.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 static BoundingSphere empty()
public static BoundingSphere infinite()
public java.lang.String toString()
toString
in class java.lang.Object