javax.media.j3d
Class BoundingSphere

java.lang.Object
  |
  +--javax.media.j3d.Bounds
        |
        +--javax.media.j3d.BoundingSphere

public class BoundingSphere
extends Bounds

This class defines a spherical bounding region which is defined by a center point and a radius.


Constructor Summary
BoundingSphere()
          Constructs and initializes a BoundingSphere with radius = 1 at 0 0 0.
BoundingSphere(Bounds boundsObject)
          Constructs and initializes a BoundingSphere from a bounding object.
BoundingSphere(Bounds[] boundsObjects)
          Constructs and initializes a BoundingSphere from an array of bounding objects.
BoundingSphere(Point3d center, double radius)
          Constructs and initializes a BoundingSphere from a center and radius.
 
Method Summary
 java.lang.Object clone()
          Creates a copy of the bounding sphere.
 Bounds closestIntersection(Bounds[] boundsObjects)
          Finds closest bounding object which intersects this bounding sphere
 void combine(Bounds boundsObject)
          Combines this bounding sphere with a bounding object so that the resulting bounding sphere encloses the original bounding sphere and the given bounds object.
 void combine(Bounds[] boundsObjects)
          Combines this bounding sphere with an array of bounding objects so that the resulting bounding sphere encloses the original bounding sphere and the given array of bounds object.
 void combine(Point3d point)
          Combines this bounding sphere with a point.
 void combine(Point3d[] points)
          Combines this bounding sphere with an array of points.
 void getCenter(Point3d center)
          Returns the position of this bounding sphere as a point.
 double getRadius()
          Returns the radius of this bounding sphere as a double.
 boolean intersect(Bounds boundsObject)
          Test for intersection with another bounds object.
 boolean intersect(Bounds[] boundsObjects)
          Test for intersection with another bounds object.
 boolean intersect(Bounds[] boundsObjects, BoundingSphere newBoundSphere)
          Test for intersection with an array of bounds objects.
 boolean intersect(Bounds boundsObject, BoundingSphere newBoundSphere)
          Test for intersection with another bounds object.
 boolean intersect(Point3d point)
          Test for intersection with a point.
 boolean intersect(Point3d origin, Vector3d direction)
          Test for intersection with a ray.
 boolean isEmpty()
          Tests whether the bounding sphere is empty.
 void set(Bounds boundsObject)
          Sets the value of this BoundingSphere.
 void setCenter(Point3d center)
          Sets the position of this bounding sphere from a point.
 void setRadius(double r)
          Sets the radius of this bounding sphere from a double.
 java.lang.String toString()
          Returns a string representation of this class.
 void transform(Bounds boundsObject, Transform3D matrix)
          Modifies the bounding sphere so that it bounds the volume generated by transforming the given bounding object.
 void transform(Transform3D trans)
          This transforms this bounding sphere by the given matrix.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundingSphere

public BoundingSphere(Point3d center,
                      double radius)
Constructs and initializes a BoundingSphere from a center and radius.
Parameters:
center - the center of the bounding sphere
radius - the radius of the bounding sphere

BoundingSphere

public BoundingSphere()
Constructs and initializes a BoundingSphere with radius = 1 at 0 0 0.

BoundingSphere

public BoundingSphere(Bounds boundsObject)
Constructs and initializes a BoundingSphere from a bounding object.
Parameters:
boundsObject - is a bounds object

BoundingSphere

public BoundingSphere(Bounds[] boundsObjects)
Constructs and initializes a BoundingSphere from an array of bounding objects.
Parameters:
bounds - an array of bounds objects
Method Detail

getRadius

public double getRadius()
Returns the radius of this bounding sphere as a double.
Returns:
the radius of the bounding sphere

setRadius

public void setRadius(double r)
Sets the radius of this bounding sphere from a double.
Parameters:
r - the new radius for the bounding sphere

getCenter

public void getCenter(Point3d center)
Returns the position of this bounding sphere as a point.
Parameters:
center - a Point to receive the center of the bounding sphere

setCenter

public void setCenter(Point3d center)
Sets the position of this bounding sphere from a point.
Parameters:
center - a Point defining the new center of the bounding sphere

set

public void set(Bounds boundsObject)
Sets the value of this BoundingSphere.
Overrides:
set in class Bounds
Parameters:
boundsObject - is another bounds object

clone

public java.lang.Object clone()
Creates a copy of the bounding sphere.
Overrides:
clone in class Bounds
Returns:
a BoundingSphere

combine

public void combine(Bounds boundsObject)
Combines this bounding sphere with a bounding object so that the resulting bounding sphere encloses the original bounding sphere and the given bounds object.
Overrides:
combine in class Bounds
Parameters:
boundsObject - another bounds object

combine

public void combine(Bounds[] boundsObjects)
Combines this bounding sphere with an array of bounding objects so that the resulting bounding sphere encloses the original bounding sphere and the given array of bounds object.
Overrides:
combine in class Bounds
Parameters:
boundsObjects - an array of bounds objects

combine

public void combine(Point3d point)
Combines this bounding sphere with a point.
Overrides:
combine in class Bounds
Parameters:
point - a 3D point in space

combine

public void combine(Point3d[] points)
Combines this bounding sphere with an array of points.
Overrides:
combine in class Bounds
Parameters:
points - an array of 3D points in space

isEmpty

public boolean isEmpty()
Tests whether the bounding sphere is empty. A bounding sphere 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 sphere with a volume of zero is not empty.
Overrides:
isEmpty in class Bounds
Returns:
true if the bounding sphere is empty; otherwise, it returns false

transform

public void transform(Bounds boundsObject,
                      Transform3D matrix)
Modifies the bounding sphere so that it bounds the volume generated by transforming the given bounding object.
Overrides:
transform in class Bounds
Parameters:
boundsObject - the bounding object to be transformed
matrix - a transformation matrix

transform

public void transform(Transform3D trans)
This transforms this bounding sphere by the given matrix.
Overrides:
transform in class Bounds

intersect

public boolean intersect(Point3d origin,
                         Vector3d direction)
Test for intersection with a ray.
Overrides:
intersect in class Bounds
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Point3d point)
Test for intersection with a point.
Overrides:
intersect in class Bounds
Parameters:
point - a point defining a position in 3-space
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds boundsObject)
Test for intersection with another bounds object.
Overrides:
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 another bounds object.
Overrides:
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,
                         BoundingSphere newBoundSphere)
Test for intersection with another bounds object.
Parameters:
boundsObject - another bounds object
newBoundSphere - the new bounding sphere which is the intersection of the boundsObject and this BoundingSphere
Returns:
true or false indicating if an intersection occured

intersect

public boolean intersect(Bounds[] boundsObjects,
                         BoundingSphere newBoundSphere)
Test for intersection with an array of bounds objects.
Parameters:
boundsObjects - an array of bounds object
newBoundSphere - the new bounding sphere which is the intersection of the boundsObject and this BoundingSphere
Returns:
true or false indicating if an intersection occured

closestIntersection

public Bounds closestIntersection(Bounds[] boundsObjects)
Finds closest bounding object which intersects this bounding sphere
Overrides:
closestIntersection in class Bounds
Parameters:
boundsObjects - is an array of bounds objects
Returns:
closest bounding object

toString

public java.lang.String toString()
Returns a string representation of this class.
Overrides:
toString in class java.lang.Object