jme.geometry.bounding
Class BoundingSphere

java.lang.Object
  extended byjme.geometry.bounding.BoundingSphere
All Implemented Interfaces:
BoundingVolume

public class BoundingSphere
extends java.lang.Object
implements BoundingVolume

BoundingSphere defines a sphere that defines a container for a group of vertices of a particular piece of geometry. This sphere defines a radius and a center. This origin is translated from the containing entity's position.

A typical usage is to allow the class define the center and radius by calling either containAABB or averagePoints.

Version:
$Id: BoundingSphere.java,v 1.5 2003/09/08 20:29:28 mojomonkey Exp $
Author:
Mark Powell

Constructor Summary
BoundingSphere()
          Default contstructor instantiates a new BoundingSphere object.
BoundingSphere(float radius, Vector center)
          Constructor instantiates a new BoundingSphere object.
 
Method Summary
 void averagePoints(Vector[] points)
          averagePoints selects the sphere center to be the average of the points and the sphere radius to be the smallest value to enclose all points.
 void containAABB(Vector[] points)
          containAABB creates a minimum-volume axis-aligned bounding box of the points, then selects the smallest enclosing sphere of the box with the sphere centered at the boxes center.
 float distance(BoundingVolume volume)
           
 Vector getCenter()
          getCenter returns the center of the bounding sphere.
 float getRadius()
          getRadius returns the radius of the bounding sphere.
 boolean hasCollision(BoundingVolume volume)
           
 boolean isVisible(Frustum frustum)
           
 void setCenter(Vector center)
          setCenter sets the center of the bounding sphere.
 void setRadius(float radius)
          setRadius sets the radius of this bounding sphere.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundingSphere

public BoundingSphere()
Default contstructor instantiates a new BoundingSphere object.


BoundingSphere

public BoundingSphere(float radius,
                      Vector center)
Constructor instantiates a new BoundingSphere object.

Parameters:
radius - the radius of the sphere.
center - the center of the sphere.
Method Detail

getRadius

public float getRadius()
getRadius returns the radius of the bounding sphere.

Returns:
the radius of the bounding sphere.

getCenter

public Vector getCenter()
getCenter returns the center of the bounding sphere.

Returns:
the center of the bounding sphere.

setRadius

public void setRadius(float radius)
setRadius sets the radius of this bounding sphere.

Parameters:
radius - the new radius of the bounding sphere.

setCenter

public void setCenter(Vector center)
setCenter sets the center of the bounding sphere.

Parameters:
center - the new center of the bounding sphere.

containAABB

public void containAABB(Vector[] points)
containAABB creates a minimum-volume axis-aligned bounding box of the points, then selects the smallest enclosing sphere of the box with the sphere centered at the boxes center.

Parameters:
points - the list of points.

averagePoints

public void averagePoints(Vector[] points)
averagePoints selects the sphere center to be the average of the points and the sphere radius to be the smallest value to enclose all points.

Parameters:
points - the list of points to contain.

hasCollision

public boolean hasCollision(BoundingVolume volume)
Specified by:
hasCollision in interface BoundingVolume

distance

public float distance(BoundingVolume volume)
Specified by:
distance in interface BoundingVolume

isVisible

public boolean isVisible(Frustum frustum)
Specified by:
isVisible in interface BoundingVolume