javax.media.j3d
Class BoundingBox

java.lang.Object
  extended by javax.media.j3d.Bounds
      extended by javax.media.j3d.BoundingBox
All Implemented Interfaces:
java.lang.Cloneable

public class BoundingBox
extends Bounds

This class defines an axis aligned bounding box which is used for bounding regions.


Field Summary
private  Point3d centroid
           
private static double EPS
           
(package private)  Point3d lower
          The corner of the bounding box with the numerically smallest values.
private static boolean releaseBoundingBoxMemory
           
private  BoundingBox tmpBox
           
private  Point3d tmpP3d
           
private  BoundingPolytope tmpPolytope
           
private  BoundingSphere tmpSphere
           
(package private)  Point3d upper
          The corner of the bounding box with the numerically largest values.
 
Fields inherited from class javax.media.j3d.Bounds
boundId, BOUNDING_BOX, BOUNDING_POLYTOPE, BOUNDING_SPHERE, boundsIsEmpty, boundsIsInfinite, debug, EPSILON
 
Constructor Summary
BoundingBox()
          Constructs and initializes a 2X bounding box about the origin.
BoundingBox(Bounds boundsObject)
          Constructs a BoundingBox from a bounding object.
BoundingBox(Bounds[] bounds)
          Constructs a BoundingBox from an array of bounding objects.
BoundingBox(Point3d lower, Point3d upper)
          Constructs and initializes a BoundingBox given min,max in x,y,z.
 
Method Summary
(package private)  boolean checkBoundsIsNaN()
           
 java.lang.Object clone()
          Creates a copy of this bounding box.
 Bounds closestIntersection(Bounds[] boundsObjects)
          Finds closest bounding object that intersects this bounding box.
 void combine(Bounds boundsObject)
          Combines this bounding box with a bounding object so that the resulting bounding box encloses the original bounding box and the specified bounds object.
 void combine(Bounds[] bounds)
          Combines this bounding box with an array of bounding objects so that the resulting bounding box encloses the original bounding box and the array of bounding objects.
 void combine(Point3d point)
          Combines this bounding box with a point so that the resulting bounding box encloses the original bounding box and the point.
 void combine(Point3d[] points)
          Combines this bounding box with an array of points so that the resulting bounding box encloses the original bounding box and the array of points.
(package private)  Bounds copy(Bounds r)
          if the passed the "region" is same type as this object then do a copy, otherwise clone the Bounds and return
 boolean equals(java.lang.Object bounds)
          Indicates whether the specified bounds object is equal to this BoundingBox object.
(package private)  Point3d getCenter()
          Returns the center of the bounds
 void getLower(Point3d p1)
          Gets the lower corner of this bounding box.
(package private)  int getPickType()
           
 void getUpper(Point3d p1)
          Gets the upper corner of this bounding box.
 int hashCode()
          Returns a hash code value for this BoundingBox object based on the data values in this object.
 boolean intersect(Bounds boundsObject)
          Test for intersection with another bounds object.
 boolean intersect(Bounds[] boundsObjects)
          Test for intersection with an array of bounds objects.
 boolean intersect(Bounds[] boundsObjects, BoundingBox newBoundBox)
          Test for intersection with an array of bounds objects.
 boolean intersect(Bounds boundsObject, BoundingBox newBoundBox)
          Test for intersection with another bounding box.
(package private)  boolean intersect(Bounds boundsObject, Point4d position)
          Test for intersection with another bounds object.
(package private)  boolean intersect(CachedFrustum frustum)
          Tests for intersection of box and frustum.
 boolean intersect(Point3d point)
          Test for intersection with a point.
(package private)  boolean intersect(Point3d start, Point3d end, Point4d position)
          Test for intersection with a segment.
(package private)  boolean intersect(Point3d point, Point4d position)
          Test for intersection with a point.
 boolean intersect(Point3d origin, Vector3d direction)
          Test for intersection with a ray.
(package private)  boolean intersect(Point3d origin, Vector3d direction, Point3d intersect)
          A protected intersect method that returns the point of intersection.
(package private)  boolean intersect(Point3d origin, Vector3d direction, Point4d position)
          Test for intersection with a ray.
 boolean isEmpty()
          Tests whether the bounding box is empty.
 void set(Bounds boundsObject)
          Sets the the value of this BoundingBox
 void setLower(double xmin, double ymin, double zmin)
          Sets the lower corner of this bounding box.
 void setLower(Point3d p1)
          Sets the lower corner of this bounding box.
 void setUpper(double xmax, double ymax, double zmax)
          Sets the upper corner of this bounding box.
 void setUpper(Point3d p1)
          Sets the upper corner of this bounding box.
 java.lang.String toString()
          Returns a string representation of this class.
 void transform(Bounds boundsObject, Transform3D matrix)
          Modifies the bounding box so that it bounds the volume generated by transforming the given bounding object.
 void transform(Transform3D matrix)
          Transforms this bounding box by the given matrix.
(package private)  void translate(BoundingBox bbox, Vector3d value)
           
private  void updateBoundsStates()
           
 
Methods inherited from class javax.media.j3d.Bounds
closest_point, getWithLock, intersect_ptope_abox, intersect_ptope_ptope, intersect_ptope_sphere, setWithLock
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

lower

Point3d lower
The corner of the bounding box with the numerically smallest values.


upper

Point3d upper
The corner of the bounding box with the numerically largest values.


centroid

private Point3d centroid

EPS

private static final double EPS
See Also:
Constant Field Values

tmpSphere

private BoundingSphere tmpSphere

tmpBox

private BoundingBox tmpBox

tmpPolytope

private BoundingPolytope tmpPolytope

tmpP3d

private Point3d tmpP3d

releaseBoundingBoxMemory

private static boolean releaseBoundingBoxMemory
Constructor Detail

BoundingBox

public BoundingBox(Point3d lower,
                   Point3d upper)
Constructs and initializes a BoundingBox given min,max in x,y,z.

Parameters:
lower - the "small" corner
upper - the "large" corner

BoundingBox

public BoundingBox()
Constructs and initializes a 2X bounding box about the origin. The lower corner is initialized to (-1.0d, -1.0d, -1.0d) and the opper corner is initialized to (1.0d, 1.0d, 1.0d).


BoundingBox

public BoundingBox(Bounds boundsObject)
Constructs a BoundingBox from a bounding object.

Parameters:
boundsObject - a bounds object

BoundingBox

public BoundingBox(Bounds[] bounds)
Constructs a BoundingBox from an array of bounding objects.

Parameters:
bounds - an array of bounding objects
Method Detail

getLower

public void getLower(Point3d p1)
Gets the lower corner of this bounding box.

Parameters:
p1 - a Point to receive the lower corner of the bounding box

setLower

public void setLower(double xmin,
                     double ymin,
                     double zmin)
Sets the lower corner of this bounding box.

Parameters:
xmin - minimum x value of boundining box
ymin - minimum y value of boundining box
zmin - minimum z value of boundining box

setLower

public void setLower(Point3d p1)
Sets the lower corner of this bounding box.

Parameters:
p1 - a Point defining the new lower corner of the bounding box

getUpper

public void getUpper(Point3d p1)
Gets the upper corner of this bounding box.

Parameters:
p1 - a Point to receive the upper corner of the bounding box

setUpper

public void setUpper(double xmax,
                     double ymax,
                     double zmax)
Sets the upper corner of this bounding box.

Parameters:
xmax - max x value of boundining box
ymax - max y value of boundining box
zmax - max z value of boundining box

setUpper

public void setUpper(Point3d p1)
Sets the upper corner of this bounding box.

Parameters:
p1 - a Point defining the new upper corner of the bounding box

set

public void set(Bounds boundsObject)
Sets the the value of this BoundingBox

Specified by:
set in class Bounds
Parameters:
boundsObject - another bounds object

clone

public java.lang.Object clone()
Creates a copy of this bounding box.

Specified by:
clone in class Bounds
Returns:
a new bounding box

equals

public boolean equals(java.lang.Object bounds)
Indicates whether the specified bounds object is equal to this BoundingBox object. They are equal if the specified bounds object is an instance of BoundingBox and all of the data members of bounds are equal to the corresponding data members in this BoundingBox.

Specified by:
equals in class Bounds
Parameters:
bounds - the object with which the comparison is made.
Returns:
true if this BoundingBox is equal to bounds; otherwise false
Since:
Java 3D 1.2

hashCode

public int hashCode()
Returns a hash code value for this BoundingBox object based on the data values in this object. Two different BoundingBox objects with identical data values (i.e., BoundingBox.equals returns true) will return the same hash code value. Two BoundingBox objects with different data members may return the same hash code value, although this is not likely.

Specified by:
hashCode in class Bounds
Returns:
a hash code value for this BoundingBox object.
Since:
Java 3D 1.2

combine

public void combine(Bounds boundsObject)
Combines this bounding box with a bounding object so that the resulting bounding box encloses the original bounding box and the specified bounds object.

Specified by:
combine in class Bounds
Parameters:
boundsObject - another bounds object

combine

public void combine(Bounds[] bounds)
Combines this bounding box with an array of bounding objects so that the resulting bounding box encloses the original bounding box and the array of bounding objects.

Specified by:
combine in class Bounds
Parameters:
bounds - an array of bounds objects

combine

public void combine(Point3d point)
Combines this bounding box with a point so that the resulting bounding box encloses the original bounding box and the point.

Specified by:
combine in class Bounds
Parameters:
point - a 3d point in space

combine

public void combine(Point3d[] points)
Combines this bounding box with an array of points so that the resulting bounding box encloses the original bounding box and the array of points.

Specified by:
combine in class Bounds
Parameters:
points - an array of 3d points in space

transform

public void transform(Bounds boundsObject,
                      Transform3D matrix)
Modifies the bounding box so that it bounds the volume generated by transforming the given bounding object.

Specified by:
transform in class Bounds
Parameters:
boundsObject - the bounding object to be transformed
matrix - a transformation matrix

transform

public void transform(Transform3D matrix)
Transforms this bounding box by the given matrix.

Specified by:
transform in class Bounds
Parameters:
matrix - a transformation matrix

intersect

boolean intersect(Point3d origin,
                  Vector3d direction,
                  Point4d position)
Test for intersection with a ray.

Specified by:
intersect in class Bounds
Parameters:
origin - the starting point of the ray
direction - the direction of the ray
position3 - a point defining the location of the pick w= distance to pick
Returns:
true or false indicating if an intersection occured

intersect

boolean intersect(Point3d point,
                  Point4d position)
Test for intersection with a point.

Specified by:
intersect in class Bounds
Parameters:
point - the pick point
position - a point defining the location of the pick w= distance to pick
Returns:
true or false indicating if an intersection occured

intersect

boolean intersect(Point3d start,
                  Point3d end,
                  Point4d position)
Test for intersection with a segment.

Specified by:
intersect in class Bounds
Parameters:
start - a point defining the start of the line segment
end - a point defining the end of the line segment
position - a point defining the location of the pick w= distance to pick
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Point3d origin,
                         Vector3d direction)
Test for intersection with a ray.

Specified by:
intersect in class Bounds
Parameters:
origin - the starting point of the ray
direction - the direction of the ray
Returns:
true or false indicating if an intersection occured

intersect

boolean intersect(Point3d origin,
                  Vector3d direction,
                  Point3d intersect)
A protected intersect method that returns the point of intersection. Used by Picking methods to sort or return closest picked item.


intersect

public boolean intersect(Point3d point)
Test for intersection with a point.

Specified by:
intersect in class Bounds
Parameters:
point - a point defining a position in 3-space
Returns:
true or false indicating if an intersection occured

isEmpty

public boolean isEmpty()
Tests whether the bounding box is empty. A bounding box is empty if it is null (either by construction or as the result of a null intersection) or if its volume is negative. A bounding box with a volume of zero is not empty.

Specified by:
isEmpty in class Bounds
Returns:
true if the bounding box is empty; otherwise, it returns false

intersect

boolean intersect(Bounds boundsObject,
                  Point4d position)
Test for intersection with another bounds object.

Specified by:
intersect in class Bounds
Parameters:
boundsObject - another bounds object
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds boundsObject)
Test for intersection with another bounds object.

Specified by:
intersect in class Bounds
Parameters:
boundsObject - another bounds object
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds[] boundsObjects)
Test for intersection with an array of bounds objects.

Specified by:
intersect in class Bounds
Parameters:
boundsObjects - an array of bounding objects
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds boundsObject,
                         BoundingBox newBoundBox)
Test for intersection with another bounding box.

Parameters:
boundsObject - another bounding object
newBoundBox - the new bounding box which is the intersection of the boundsObject and this BoundingBox
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds[] boundsObjects,
                         BoundingBox newBoundBox)
Test for intersection with an array of bounds objects.

Parameters:
boundsObjects - an array of bounds objects
newBoundBox - the new bounding box which is the intersection of the boundsObject and this BoundingBox
Returns:
true or false indicating if an intersection occured

closestIntersection

public Bounds closestIntersection(Bounds[] boundsObjects)
Finds closest bounding object that intersects this bounding box.

Specified by:
closestIntersection in class Bounds
Parameters:
boundsObjects - an array of bounds objects
Returns:
closest bounding object

intersect

boolean intersect(CachedFrustum frustum)
Tests for intersection of box and frustum.

Parameters:
frustum -
Returns:
true if they intersect

toString

public java.lang.String toString()
Returns a string representation of this class.

Overrides:
toString in class java.lang.Object

updateBoundsStates

private void updateBoundsStates()

getCenter

Point3d getCenter()
Description copied from class: Bounds
Returns the center of the bounds

Specified by:
getCenter in class Bounds
Returns:
bounds center

translate

void translate(BoundingBox bbox,
               Vector3d value)

copy

Bounds copy(Bounds r)
if the passed the "region" is same type as this object then do a copy, otherwise clone the Bounds and return

Specified by:
copy in class Bounds

checkBoundsIsNaN

boolean checkBoundsIsNaN()

getPickType

int getPickType()
Specified by:
getPickType in class Bounds


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.