org.openmali.spatial.bodies
Class Sphere

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

public class Sphere
extends Body
implements java.io.Serializable

An efficient Sphere. Creation date: (06/02/2001 00:08:09)

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.spatial.bodies.Body
centerX, centerY, centerZ, distComputed, maxCenterDist, maxCenterDistSquared
 
Constructor Summary
Sphere()
          Creates a BoundingSphere.
Sphere(float x, float y, float z, float radius)
          Creates a BoundingSphere.
Sphere(Tuple3f center, float radius)
          Creates a BoundingSphere.
 
Method Summary
 void combine(BodyInterface body)
          Combines this Body with a bounding object.
 void combine(BodyInterface[] bos)
          Combines this Body with an array of bounding objects.
 void combine(float px, float py, float pz)
          Combines this Body with a point.
 void combine(Point3f point)
          Combines this Body with a point.
 void combine(Point3f[] points)
          Combine this Body with an array of points.
 boolean contains(float px, float py, float pz)
          Tests, if the given point is inside of this Body.
 boolean contains(Point3f point)
          Tests, if the given point is inside of this Body.
 boolean containsPlus(float px, float py, float pz, float distance)
          Checks, if the 2D-point is in the XY-projected circle.
 boolean containsXYPlus(float px, float py, float distance)
          Checks, if the 2D-point is in the XY-projected circle.
 Point3f getCenter()
           
 float getRadius()
           
 float getRadiusSquared()
           
 void setRadius(float radius)
          Sets the Sphere's radius.
 java.lang.String toString()
          
 
Methods inherited from class org.openmali.spatial.bodies.Body
getCenter, getCenterX, getCenterY, getCenterZ, getMaxCenterDistance, getMaxCenterDistanceSquared, setCenter, setCenter, setMaxCenterDistanceSquared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sphere

public Sphere(float x,
              float y,
              float z,
              float radius)
Creates a BoundingSphere.


Sphere

public Sphere(Tuple3f center,
              float radius)
Creates a BoundingSphere.


Sphere

public Sphere()
Creates a BoundingSphere.

Method Detail

getCenter

public final Point3f getCenter()
Returns:
this Sphere's center point.

setRadius

public void setRadius(float radius)
Sets the Sphere's radius.

Parameters:
radius -

getRadius

public final float getRadius()
Returns:
the Sphere's radius.

getRadiusSquared

public final float getRadiusSquared()
Returns:
the square of the Sphere's radius.

containsXYPlus

public boolean containsXYPlus(float px,
                              float py,
                              float distance)
Checks, if the 2D-point is in the XY-projected circle.

Parameters:
px -
py -
distance - the distance to (virtually) expand the radius by for this check

containsPlus

public boolean containsPlus(float px,
                            float py,
                            float pz,
                            float distance)
Checks, if the 2D-point is in the XY-projected circle.

Parameters:
px -
py -
distance - the distance to (virtually) expand the radius by for this check

contains

public boolean contains(float px,
                        float py,
                        float pz)
Tests, if the given point is inside of this Body.

Specified by:
contains in interface BodyInterface
Returns:
true, if it is inside

contains

public boolean contains(Point3f point)
Tests, if the given point is inside of this Body.

Specified by:
contains in interface BodyInterface
Returns:
true, if it is inside

combine

public void combine(BodyInterface body)
Combines this Body with a bounding object.

Specified by:
combine in interface BodyInterface

combine

public void combine(BodyInterface[] bos)
Combines this Body with an array of bounding objects.

Specified by:
combine in interface BodyInterface

combine

public void combine(float px,
                    float py,
                    float pz)
Combines this Body with a point.

Specified by:
combine in interface BodyInterface

combine

public void combine(Point3f point)
Combines this Body with a point.

Specified by:
combine in interface BodyInterface

combine

public void combine(Point3f[] points)
Combine this Body with an array of points.

Specified by:
combine in interface BodyInterface

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object