|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sunflow.math.BoundingBox
public class BoundingBox
3D axis-aligned bounding box. Stores only the minimum and maximum corner points.
Constructor Summary | |
---|---|
BoundingBox()
Creates an empty box. |
|
BoundingBox(BoundingBox b)
Creates a copy of the given box. |
|
BoundingBox(float size)
Creates a bounding box centered around the origin. |
|
BoundingBox(float x,
float y,
float z)
Creates a bounding box containing only the specified point. |
|
BoundingBox(Point3 p)
Creates a bounding box containing only the specified point. |
Method Summary | |
---|---|
boolean |
contains(float x,
float y,
float z)
Check to see if the specified point is inside the volume defined by this box. |
boolean |
contains(Point3 p)
Checks to see if the specified point is
inside the volume defined by this box. |
void |
enlargeUlps()
Enlarge the bounding box by the minimum possible amount to avoid numeric precision related problems. |
float |
getArea()
Gets the surface area of the box. |
float |
getBound(int i)
Gets a specific coordinate of the surface's bounding box. |
Point3 |
getCenter()
Gets the center of the box, computed as (min + max) / 2. |
Point3 |
getCorner(int i)
Gets a corner of the bounding box. |
Vector3 |
getExtents()
Gets the extents vector for the box. |
Point3 |
getMaximum()
Gets the maximum corner of the box. |
Point3 |
getMinimum()
Gets the minimum corner of the box. |
float |
getVolume()
Gets the box's volume |
void |
include(BoundingBox b)
Changes the extents of the box as needed to include the given box into this box. |
void |
include(float x,
float y,
float z)
Changes the extents of the box as needed to include the given point into this box. |
void |
include(Point3 p)
Changes the extents of the box as needed to include the given point into this box. |
boolean |
intersects(BoundingBox b)
Returns true if the specified bounding box intersects this
one. |
boolean |
isEmpty()
Returns true when the box has just been initialized, and
is still empty. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BoundingBox()
public BoundingBox(BoundingBox b)
b
- bounding box to copypublic BoundingBox(Point3 p)
p
- point to includepublic BoundingBox(float x, float y, float z)
x
- x coordinate of the point to includey
- y coordinate of the point to includez
- z coordinate of the point to includepublic BoundingBox(float size)
size
- half edge length of the bounding boxMethod Detail |
---|
public final Point3 getMinimum()
public final Point3 getMaximum()
public final Point3 getCenter()
public final Point3 getCorner(int i)
i
- a corner index, from 0 to 7
public final float getBound(int i)
i
- index of a side from 0 to 5
public final Vector3 getExtents()
Vector3.length()
public final float getArea()
public final float getVolume()
public final void enlargeUlps()
public final boolean isEmpty()
true
when the box has just been initialized, and
is still empty. This method might also return true if the state of the
box becomes inconsistent and some component of the minimum corner is
larger than the corresponding coordinate of the maximum corner.
true
if the box is empty, false
otherwisepublic final boolean intersects(BoundingBox b)
true
if the specified bounding box intersects this
one. The boxes are treated as volumes, so a box inside another will
return true. Returns false
if the parameter is
null
.
b
- box to be tested for intersection
true
if the boxes overlap, false
otherwisepublic final boolean contains(Point3 p)
point
is
inside the volume defined by this box. Returns false
if
the parameter is null
.
p
- point to be tested for containment
true
if the point is inside the box,
false
otherwisepublic final boolean contains(float x, float y, float z)
x
- x coordinate of the point to be testedy
- y coordinate of the point to be testedz
- z coordinate of the point to be tested
true
if the point is inside the box,
false
otherwisepublic final void include(Point3 p)
point
into this box. Does nothing if the
parameter is null
.
p
- point to be includedpublic final void include(float x, float y, float z)
x
- x coordinate of the pointy
- y coordinate of the pointz
- z coordinate of the pointpublic final void include(BoundingBox b)
null
.
b
- box to be includedpublic final java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |