org.openmali.spatial.bodies
Class Sphere

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

public class Sphere
extends java.lang.Object
implements java.io.Serializable, Body

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

Author:
Jack Ritter from "Graphics Gems", Academic Press, 1990, cas, Marvin Froehlich (aka Qudus)
See Also:
Serialized Form

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(Body body)
          Combines this Body with a bounding object.
 void combine(Body[] 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()
           
 Tuple3f getCenter(Tuple3f center)
          Gets this Sphere's center point.
 float getCenterX()
           
 float getCenterY()
           
 float getCenterZ()
           
 float getRadius()
           
 float getRadiusSquared()
           
 void setCenter(float cx, float cy, float cz)
          Sets this Sphere's center point.
 void setCenter(Tuple3f center)
          Sets this Sphere's center point.
 void setRadius(float radius)
          Sets the Sphere's radius.
 java.lang.String toString()
          
 
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

setCenter

public void setCenter(float cx,
                      float cy,
                      float cz)
Sets this Sphere's center point.

Parameters:
cx -
cy -
cz -

setCenter

public void setCenter(Tuple3f center)
Sets this Sphere's center point.

Parameters:
center -

getCenter

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

getCenter

public Tuple3f getCenter(Tuple3f center)
Gets this Sphere's center point.

Parameters:
center -

getCenterX

public float getCenterX()
Returns:
the Sphere's center point's x coordinate.

getCenterY

public float getCenterY()
Returns:
the Sphere's center point's y coordinate.

getCenterZ

public float getCenterZ()
Returns:
the Sphere's center point's z coordinate.

setRadius

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

Parameters:
radius -

getRadius

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

getRadiusSquared

public 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 Body
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 Body
Returns:
true, if it is inside

combine

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

Specified by:
combine in interface Body

combine

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

Specified by:
combine in interface Body

combine

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

Specified by:
combine in interface Body

combine

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

Specified by:
combine in interface Body

combine

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

Specified by:
combine in interface Body

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object