@PublicAPI public class BoundingBox extends java.lang.Object
GraphicComponent
has a BoundingBox
by default, but it has to be set.
Edges of bounding boxes are always parallel to the coordinate axes. BoundingBox bb = new BoundingBox( 1, 2, 3, 4, 5, 6);
BoundingBox bb = new BoundingBox(); for(int i=0; i<atomCount; i++) { bb.setWithCondition(atomx, atomy, atomz); } bb.ready();
Constructor and Description |
---|
BoundingBox()
Creates a new instance of BoundingBox but does not set anything.
|
BoundingBox(float minx,
float miny,
float minz,
float maxx,
float maxy,
float maxz)
Creates a bounding box with the given coordinates, computes the center and radius of the box.
|
Modifier and Type | Method and Description |
---|---|
float |
centerx()
Returns the x coordinate of the center of the box.
|
float |
centery()
Returns the y coordinate of the center of the box.
|
float |
centerz()
Returns the z coordinate of the center of the box.
|
void |
clear()
Clears all previously set coordinate from the box.
|
boolean |
contains(float x,
float y,
float z)
Tells whether the given location is inside the box.
|
void |
draw(javax.media.opengl.GL2 gl)
Draws the box with the given GL2 in line mode.
|
void |
extend(float v)
Makes the bounding box being larger or smaller by the given value in each
direction.
|
void |
finalize() |
float[] |
getBoundingCenter()
Returns the center of the box as a vector.
|
double |
getBoundingRadius()
Returns the radius of the bounding sphere of the box, which is
the distance between the lower-left-front corner and the center.
|
float |
getMaxX()
Returns the maximum x coordinate of the box.
|
float |
getMaxY()
Returns the maximum y coordinate of the box.
|
float |
getMaxZ()
Returns the maximum z coordinate of the box.
|
float |
getMinX()
Returns the minimum x coordinate of the box.
|
float |
getMinY()
Returns the minimum y coordinate of the box.
|
float |
getMinZ()
Returns the minimum z coordinate of the box.
|
float |
maxx()
Returns the maximum x coordinate of the box.
|
float |
maxy()
Returns the maximum y coordinate of the box.
|
float |
maxz()
Returns the maximum z coordinate of the box.
|
float |
minx()
Returns the minimum x coordinate of the box.
|
float |
miny()
Returns the minimum y coordinate of the box.
|
float |
minz()
Returns the minimum z coordinate of the box.
|
void |
ready()
It has to be called after passing all coordinates to the box.
|
void |
set(float minx,
float miny,
float minz,
float maxx,
float maxy,
float maxz)
Sets the minimum and maximum coordinates of the box.
|
void |
setMax(float maxx,
float maxy,
float maxz)
Sets the maximum coordinates of the box.
|
void |
setMaxX(float v)
Sets the maximum x coordinate of the box.
|
void |
setMaxY(float v)
Sets the maximum y coordinate of the box.
|
void |
setMaxZ(float v)
Sets the maximum z coordinate of the box.
|
void |
setMin(float minx,
float miny,
float minz)
Sets the minimum coordinates of the box.
|
void |
setMinX(float v)
Sets the minimum x coordinate of the box.
|
void |
setMinY(float v)
Sets the minimum y coordinate of the box.
|
void |
setMinZ(float v)
Sets the minimum z coordinate of the box.
|
void |
setWithCondition(BoundingBox bb)
Extends the box with the given box, say gives the bounding box of the two boxes.
|
void |
setWithCondition(float x,
float y,
float z)
This is the best way of passing coordinates to the box.
|
java.lang.String |
toString()
Returns the minimum and maximum coordinates of the box.
|
void |
translate(float[] v)
A box can be translated in space.
|
public BoundingBox()
public BoundingBox(float minx, float miny, float minz, float maxx, float maxy, float maxz)
public void finalize()
finalize
in class java.lang.Object
public void draw(javax.media.opengl.GL2 gl)
gl
- Interface to OpenGLpublic float minx()
public float miny()
public float minz()
public float getMinX()
public float getMinY()
public float getMinZ()
public void setMin(float minx, float miny, float minz)
minx
- minimum x coordinateminy
- minimum y coordinateminz
- minimum z coordinatepublic void setMinX(float v)
v
- minimum x coordinatepublic void setMinY(float v)
v
- minimum y coordinatepublic void setMinZ(float v)
v
- minimum z coordinatepublic float maxx()
public float maxy()
public float maxz()
public float getMaxX()
public float getMaxY()
public float getMaxZ()
public void setMax(float maxx, float maxy, float maxz)
maxx
- maximum x coordinatemaxy
- maximum y coordinatemaxz
- maximum z coordinatepublic void setMaxX(float v)
v
- maximum x coordinatepublic void setMaxY(float v)
v
- maximum y coordinatepublic void setMaxZ(float v)
v
- maximum z coordinatepublic float centerx()
public float centery()
public float centerz()
public void clear()
public void ready()
public void set(float minx, float miny, float minz, float maxx, float maxy, float maxz)
minx
- minimum x coordinateminy
- minimum y coordinateminz
- minimum z coordinatemaxx
- maximum x coordinatemaxy
- maximum y coordinatemaxz
- maximum z coordinatepublic void setWithCondition(float x, float y, float z)
x
- possible minimum and maximum x coordinatey
- possible minimum and maximum y coordinatez
- possible minimum and maximum z coordinatepublic void setWithCondition(BoundingBox bb)
bb
- volume to add to the current volume defined by the boxespublic void extend(float v)
v
- extension in Angstromspublic float[] getBoundingCenter()
public double getBoundingRadius()
public boolean contains(float x, float y, float z)
public void translate(float[] v)
LocationControl
.v
- translation vectorpublic java.lang.String toString()
toString
in class java.lang.Object
String