net.java.dev.joode.util
Class AABB3f

java.lang.Object
  extended by net.java.dev.joode.util.AABB3f

public class AABB3f
extends java.lang.Object

An 3-D axis-aligned bounding box represented using single-precision coordinates. This represents a bounding volume about an object or group of objects as a box aligned with the coordinate system axes.

An empty volume is represented by any of minX, minY or minZ being greater than the corresponding maxX, maxY or maxZ.

Author:
Art Pope

Field Summary
 float maxX
          The maximum X coordinate of the bounding volume.
 float maxY
          The maximum Y coordinate of the bounding volume.
 float maxZ
          The maximum Z coordinate of the bounding volume.
 float minX
          The minimum X coordinate of the bounding volume.
 float minY
          The minimum Y coordinate of the bounding volume.
 float minZ
          The minimum Z coordinate of the bounding volume.
 
Constructor Summary
AABB3f()
          Constructs an empty AABB.
AABB3f(float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
          Constructs an AABB with specified bounds.
 
Method Summary
 void empty()
          Sets this bounding volume to empty.
 AABB3f intersection(AABB3f box2)
          Finds the intersection of this AABB with another.
 boolean intersects(AABB3f box2)
          Tests whether this AABB intersects another.
 boolean isEmpty()
          Tests whether this bounding volume is empty.
 void merge(AABB3f box2)
          Sets this AABB to the union of it and another AABB.
 void setBounds(AABB3f src)
          Copies the bounds from another AABB.
 void setBounds(Point3f p0, Point3f p1, Point3f p2)
          Sets the bounds to the bounding volume of three points.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minX

public float minX
The minimum X coordinate of the bounding volume.


maxX

public float maxX
The maximum X coordinate of the bounding volume.


minY

public float minY
The minimum Y coordinate of the bounding volume.


maxY

public float maxY
The maximum Y coordinate of the bounding volume.


minZ

public float minZ
The minimum Z coordinate of the bounding volume.


maxZ

public float maxZ
The maximum Z coordinate of the bounding volume.

Constructor Detail

AABB3f

public AABB3f()
Constructs an empty AABB. The AABB is initialized to represent an empty volume.


AABB3f

public AABB3f(float minX,
              float maxX,
              float minY,
              float maxY,
              float minZ,
              float maxZ)
Constructs an AABB with specified bounds.

Parameters:
minX - the minimum X coordinate of the new bounding volume
maxX - the maximum X coordinate of the new bounding volume
minY - the minimum Y coordinate of the new bounding volume
maxY - the maximum Y coordinate of the new bounding volume
minZ - the minimum Z coordinate of the new bounding volume
maxZ - the maximum Z coordinate of the new bounding volume
Method Detail

empty

public void empty()
Sets this bounding volume to empty.


isEmpty

public boolean isEmpty()
Tests whether this bounding volume is empty.

Returns:
true if the extent of the volume is negative along all three dimensions.

intersection

public AABB3f intersection(AABB3f box2)
Finds the intersection of this AABB with another.

Parameters:
box2 - the other AABB
Returns:
the AABB that is the intersection of the two AABBs

intersects

public boolean intersects(AABB3f box2)
Tests whether this AABB intersects another. AABBs are considered to intersect even if they only touch (i.e., a minimum coordinate of one is equal to a maximum coordinate of the other).

Parameters:
box2 - the other AABB
Returns:
true if the two AABBs intersect

merge

public void merge(AABB3f box2)
Sets this AABB to the union of it and another AABB.

Parameters:
box2 - the other AABB

Invoking this method on an empty bounding volume is equivalent to invoking {#link setBounds(AABB3f)}. Invoking it with an empty bounding volume has no effect.


setBounds

public void setBounds(AABB3f src)
Copies the bounds from another AABB.

Parameters:
src - the AABB to be copied

setBounds

public void setBounds(Point3f p0,
                      Point3f p1,
                      Point3f p2)
Sets the bounds to the bounding volume of three points.

Parameters:
p0 - a point that is to lie within the new bounding volume
p1 - a point that is to lie within the new bounding volume
p2 - a point that is to lie within the new bounding volume