org.openmali.spatial.bodies
Class Box

java.lang.Object
  extended by org.openmali.spatial.bodies.Body
      extended by org.openmali.spatial.bodies.Box
All Implemented Interfaces:
java.io.Serializable, BodyInterface
Direct Known Subclasses:
BoundingBox, OcCell, QuadCell

public class Box
extends Body
implements java.io.Serializable

An Axis-Aligned Box.

See Also:
Serialized Form

Field Summary
protected  Point3f lower
          The lower corner of this bounding box
protected  Point3f upper
          The upper corner of this bounding box
 
Fields inherited from class org.openmali.spatial.bodies.Body
centerX, centerY, centerZ, distComputed, maxCenterDist, maxCenterDistSquared
 
Constructor Summary
Box()
          Creates a new Box
Box(float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
          Creates a new Box
Box(Tuple3f lower, Tuple3f upper)
          Creates a new Box
 
Method Summary
protected  void calcCenter()
           
protected  void combine_(float x, float y, float z)
           
protected  void combine_(Point3f p)
           
 void combine(BodyInterface body)
          Combines this Body with a bounding object.
 void combine(BodyInterface[] bodies)
          Combines this Body with an array of bounding objects.
 void combine(float x, float y, float z)
          Combines this Body with a point.
 void combine(Point3f p)
          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.
 Point3f getLower()
           
 void getLower(Tuple3f point)
           
 float getLowerX()
           
 float getLowerY()
           
 float getLowerZ()
           
 Tuple3f getSize()
          Computes the x-, y-, and z-span of this Box and puts the values into out.
<T extends Tuple3f>
T
getSize(T out)
          Computes the x-, y-, and z-span of this Box and puts the values into out.
 Point3f getUpper()
           
 void getUpper(Tuple3f point)
           
 float getUpperX()
           
 float getUpperY()
           
 float getUpperZ()
           
 float getXSpan()
           
 float getYSpan()
           
 float getZSpan()
           
protected  void onBoundsChanged()
           
 void set(float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
           
 void set(Tuple3f lower, Tuple3f upper)
           
 void setCenter(float x, float y, float z)
          Moves this Box to a position, where it's center is at the given location.
 void setLower(float x, float y, float z)
           
 void setLower(Tuple3f point)
          Sets the lower corner of this bounding box
 void setLowerX(float x)
          Sets the x coordinate of the lower corner of this Box.
 void setLowerY(float y)
          Sets the y coordinate of the lower corner of this Box.
 void setLowerZ(float z)
          Sets the z coordinate of the lower corner of this Box.
 void setSize(float xSpan, float ySpan, float zSpan)
          Resizes this Box to the given size.
 void setSize(Tuple3f span)
          Resizes this Box to the given size.
 void setUpper(float x, float y, float z)
           
 void setUpper(Tuple3f point)
          Sets the upper corner of this box
 void setUpperX(float x)
          Sets the x coordinate of the upper corner of this Box.
 void setUpperY(float y)
          Sets the y coordinate of the upper corner of this Box.
 void setUpperZ(float z)
          Sets the z coordinate of the upper corner of this Box.
 java.lang.String toString()
          
 
Methods inherited from class org.openmali.spatial.bodies.Body
getCenter, getCenterX, getCenterY, getCenterZ, getMaxCenterDistance, getMaxCenterDistanceSquared, setCenter, setMaxCenterDistanceSquared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lower

protected Point3f lower
The lower corner of this bounding box


upper

protected Point3f upper
The upper corner of this bounding box

Constructor Detail

Box

public Box(float lowerX,
           float lowerY,
           float lowerZ,
           float upperX,
           float upperY,
           float upperZ)
Creates a new Box


Box

public Box(Tuple3f lower,
           Tuple3f upper)
Creates a new Box


Box

public Box()
Creates a new Box

Method Detail

contains

public final 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 final 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

onBoundsChanged

protected void onBoundsChanged()

calcCenter

protected final void calcCenter()

set

public final void set(float lowerX,
                      float lowerY,
                      float lowerZ,
                      float upperX,
                      float upperY,
                      float upperZ)

set

public final void set(Tuple3f lower,
                      Tuple3f upper)

setLower

public final void setLower(float x,
                           float y,
                           float z)

setLower

public final void setLower(Tuple3f point)
Sets the lower corner of this bounding box


setLowerX

public final void setLowerX(float x)
Sets the x coordinate of the lower corner of this Box.

Parameters:
x -

setLowerY

public final void setLowerY(float y)
Sets the y coordinate of the lower corner of this Box.

Parameters:
y -

setLowerZ

public final void setLowerZ(float z)
Sets the z coordinate of the lower corner of this Box.

Parameters:
z -

getLower

public final Point3f getLower()
Returns:
the lower corner of this Box.

getLower

public final void getLower(Tuple3f point)

getLowerX

public final float getLowerX()
Returns:
the x coordinate of the lower corner of this Box.

getLowerY

public final float getLowerY()
Returns:
the y coordinate of the lower corner of this Box.

getLowerZ

public final float getLowerZ()
Returns:
the z coordinate of the lower corner of this Box.

setUpper

public final void setUpper(float x,
                           float y,
                           float z)

setUpper

public final void setUpper(Tuple3f point)
Sets the upper corner of this box


setUpperX

public final void setUpperX(float x)
Sets the x coordinate of the upper corner of this Box.

Parameters:
x -

setUpperY

public final void setUpperY(float y)
Sets the y coordinate of the upper corner of this Box.

Parameters:
y -

setUpperZ

public final void setUpperZ(float z)
Sets the z coordinate of the upper corner of this Box.

Parameters:
z -

getUpper

public final Point3f getUpper()
Returns:
the upper corner of this box.

getUpper

public final void getUpper(Tuple3f point)

getUpperX

public final float getUpperX()
Returns:
the x coordinate of the upper corner of this Box.

getUpperY

public final float getUpperY()
Returns:
the y coordinate of the upper corner of this Box.

getUpperZ

public final float getUpperZ()
Returns:
the z coordinate of the upper corner of this Box.

getXSpan

public final float getXSpan()

getYSpan

public final float getYSpan()

getZSpan

public final float getZSpan()

setCenter

public final void setCenter(float x,
                            float y,
                            float z)
Moves this Box to a position, where it's center is at the given location.

Overrides:
setCenter in class Body
Parameters:
x -
y -
z -

setSize

public void setSize(float xSpan,
                    float ySpan,
                    float zSpan)
Resizes this Box to the given size.

Parameters:
xSpan -
ySpan -
zSpan -

setSize

public final void setSize(Tuple3f span)
Resizes this Box to the given size.


getSize

public final <T extends Tuple3f> T getSize(T out)
Computes the x-, y-, and z-span of this Box and puts the values into out.

Parameters:
out -

getSize

public final Tuple3f getSize()
Computes the x-, y-, and z-span of this Box and puts the values into out.


combine

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

Specified by:
combine in interface BodyInterface

combine

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

Specified by:
combine in interface BodyInterface

combine_

protected final void combine_(float x,
                              float y,
                              float z)

combine

public final void combine(float x,
                          float y,
                          float z)
Combines this Body with a point.

Specified by:
combine in interface BodyInterface

combine_

protected final void combine_(Point3f p)

combine

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

Specified by:
combine in interface BodyInterface

combine

public final 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