org.openmali.spatial.bounds
Class BoundingSphere

java.lang.Object
  extended by org.openmali.spatial.bodies.Sphere
      extended by org.openmali.spatial.bounds.BoundingSphere
All Implemented Interfaces:
java.io.Serializable, Body, Bounds
Direct Known Subclasses:
OcNode

public class BoundingSphere
extends Sphere
implements Bounds

A spherical bounding volume. It has two associated values: the center point and the radius of the sphere.

Author:
David Yazel, Marvin Froehlich (aka Qudus)
See Also:
Serialized Form

Constructor Summary
BoundingSphere()
          Constructs a new BoundingShpere object.
BoundingSphere(Bounds bo)
          Constructs a new BoundingShpere object.
BoundingSphere(Bounds[] bos)
          Constructs a new BoundingShpere object.
BoundingSphere(float centerX, float centerY, float centerZ, float radius)
          Constructs a new BoundingShpere object.
BoundingSphere(Tuple3f center, float radius)
          Constructs a new BoundingShpere object.
 
Method Summary
 Bounds closestIntersection(Bounds[] boundsObjects)
          Finds closest bounding object that intersects this bounding object.
 void compute(java.util.List<Tuple3f> coords)
          Routine to calculate tight bounding sphere over a set of points in 3D.
 void compute(Tuple3f[] coords)
          Routine to calculate tight bounding sphere over a set of points in 3D.
 void compute(VertexContainer source)
          Calculates a tight bounding sphere over a set of points in 3D.
 float getMaxDistance()
          
 float getMaxSquaredDistance()
          
 BoundsType getType()
          
 boolean intersects(Bounds bo)
          Tests for intersection with another Bounds object.
 boolean intersects(Bounds[] bos)
          Tests for intersection with an array of Bounds objects.
 boolean intersects(Point3f rayOrigin, Vector3f rayDirection)
          Tests for intersection with a ray.
 boolean intersects(Point3f rayOrigin, Vector3f rayDirection, Tuple3f intersection)
          Tests for intersection with a ray.
 boolean intersects(Ray3f ray)
          Tests for intersection with a ray.
 boolean intersects(Ray3f ray, Tuple3f intersection)
          Tests for intersection with a ray.
static BoundingSphere newBoundingSphere(java.util.List<Tuple3f> coords)
          Routine to calculate tight bounding sphere over a set of points in 3D.
static BoundingSphere newBoundingSphere(Tuple3f[] coords)
          Routine to calculate tight bounding sphere over a set of points in 3D.
static BoundingSphere newBoundingSphere(VertexContainer source)
          Routine to calculate tight bounding sphere over a set of points in 3D.
 void set(Bounds boundsObject)
          Sets the the value of this Bounds object to enclode the specified bounding object
 void set(Bounds[] bos)
          Sets this bounds to the comnination of all the specified bounds.
 java.lang.String toString()
          
 void transform(Bounds bounds, Matrix4f trans)
          Transforms a Bounds object so that it bounds a volume that is the result of transforming the given bounding object by the given transform.
 void transform(Matrix4f trans)
          Transforms the Bounds object by the given transform.
 
Methods inherited from class org.openmali.spatial.bodies.Sphere
combine, combine, combine, combine, combine, contains, contains, containsPlus, containsXYPlus, getCenter, getCenter, getCenterX, getCenterY, getCenterZ, getRadius, getRadiusSquared, setCenter, setCenter, setRadius
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmali.spatial.bounds.Bounds
combine, combine, combine, contains, contains, getCenter
 
Methods inherited from interface org.openmali.spatial.bodies.Body
combine, combine
 

Constructor Detail

BoundingSphere

public BoundingSphere(float centerX,
                      float centerY,
                      float centerZ,
                      float radius)
Constructs a new BoundingShpere object.

Parameters:
centerX -
centerY -
centerZ -
radius -

BoundingSphere

public BoundingSphere(Tuple3f center,
                      float radius)
Constructs a new BoundingShpere object.


BoundingSphere

public BoundingSphere()
Constructs a new BoundingShpere object.


BoundingSphere

public BoundingSphere(Bounds bo)
Constructs a new BoundingShpere object.


BoundingSphere

public BoundingSphere(Bounds[] bos)
Constructs a new BoundingShpere object.

Method Detail

getType

public final BoundsType getType()

Specified by:
getType in interface Bounds
Returns:
the BoundsType of this Bounds instance.

getMaxSquaredDistance

public final float getMaxSquaredDistance()

Specified by:
getMaxSquaredDistance in interface Bounds
Returns:
the largest distance (squared) from the center

getMaxDistance

public final float getMaxDistance()

Specified by:
getMaxDistance in interface Bounds
Returns:
the largest distance from the center

intersects

public boolean intersects(Point3f rayOrigin,
                          Vector3f rayDirection,
                          Tuple3f intersection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Ray3f ray,
                          Tuple3f intersection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Point3f rayOrigin,
                          Vector3f rayDirection)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Ray3f ray)
Tests for intersection with a ray.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Bounds bo)
Tests for intersection with another Bounds object.

Specified by:
intersects in interface Bounds

intersects

public boolean intersects(Bounds[] bos)
Tests for intersection with an array of Bounds objects.

Specified by:
intersects in interface Bounds

closestIntersection

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

Specified by:
closestIntersection in interface Bounds

transform

public void transform(Matrix4f trans)
Transforms the Bounds object by the given transform.

Specified by:
transform in interface Bounds

transform

public void transform(Bounds bounds,
                      Matrix4f trans)
Transforms a Bounds object so that it bounds a volume that is the result of transforming the given bounding object by the given transform.

Specified by:
transform in interface Bounds

set

public void set(Bounds boundsObject)
Sets the the value of this Bounds object to enclode the specified bounding object

Specified by:
set in interface Bounds

set

public void set(Bounds[] bos)
Sets this bounds to the comnination of all the specified bounds. Any current bounds information is replaced with this new combination

Specified by:
set in interface Bounds

compute

public void compute(VertexContainer source)
Calculates a tight bounding sphere over a set of points in 3D.

Specified by:
compute in interface Bounds
Parameters:
source - the Vertex-source

compute

public void compute(java.util.List<Tuple3f> coords)
Routine to calculate tight bounding sphere over a set of points in 3D. This contains the routine find_bounding_sphere(), the struct definition, and the globals used for parameters. The abs() of all coordinates must be < Float.MAX_VALUE.

Code written by Jack Ritter and Lyle Rains.

Specified by:
compute in interface Bounds
Parameters:
coords - the Vertices

compute

public void compute(Tuple3f[] coords)
Routine to calculate tight bounding sphere over a set of points in 3D. This contains the routine find_bounding_sphere(), the struct definition, and the globals used for parameters. The abs() of all coordinates must be < Float.MAX_VALUE.

Code written by Jack Ritter and Lyle Rains.

Specified by:
compute in interface Bounds
Parameters:
coords - the Vertices

toString

public java.lang.String toString()

Overrides:
toString in class Sphere

newBoundingSphere

public static BoundingSphere newBoundingSphere(VertexContainer source)
Routine to calculate tight bounding sphere over a set of points in 3D. This contains the routine find_bounding_sphere(), the struct definition, and the globals used for parameters. The abs() of all coordinates must be < Float.MAX_VALUE. Code written by Jack Ritter and Lyle Rains.

Parameters:
source - the Vertex-source
Returns:
the BoundingSphere

newBoundingSphere

public static BoundingSphere newBoundingSphere(java.util.List<Tuple3f> coords)
Routine to calculate tight bounding sphere over a set of points in 3D. This contains the routine find_bounding_sphere(), the struct definition, and the globals used for parameters. The abs() of all coordinates must be < Float.MAX_VALUE. Code written by Jack Ritter and Lyle Rains.

Parameters:
coords - the vertex list
Returns:
the BoundingSphere

newBoundingSphere

public static BoundingSphere newBoundingSphere(Tuple3f[] coords)
Routine to calculate tight bounding sphere over a set of points in 3D. This contains the routine find_bounding_sphere(), the struct definition, and the globals used for parameters. The abs() of all coordinates must be < Float.MAX_VALUE. Code written by Jack Ritter and Lyle Rains.

Parameters:
coords - the vertex list
Returns:
the BoundingSphere