org.openmali.spatial.bodies
Class Box

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

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

An Axis-Aligned Box.

Author:
David Yazel, Marvin Froehlich (aka Qudus)
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
 
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(Body body)
          Combines this Body with a bounding object.
 void combine(Body[] 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 getCenter()
          Computes the x-, y-, and z-span of this Box and puts the values into out.
 Tuple3f getCenter(Tuple3f out)
          Computes the x-, y-, and z-span of this Box and puts the values into out.
 float getCenterX()
          Computes the xspan of this Box.
 float getCenterY()
          Computes the xspan of this Box.
 float getCenterZ()
          Computes the xspan of this Box.
 Point3f getLower()
           
 void getLower(Tuple3f point)
           
 float getLowerX()
           
 float getLowerY()
           
 float getLowerZ()
           
 float getMaxDistance()
           
 float getMaxSquaredDistance()
           
 Tuple3f getSize()
          Computes the x-, y-, and z-span of this Box and puts the values into out.
 void getSize(Tuple3f 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()
           
 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 setCenter(Tuple3f point)
          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.
protected  void setMaxSquaredDistance(float distSq)
          Sets the largest distance (squared) from the center
 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 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 Body
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 Body
Returns:
true, if it is inside

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.


setCenter

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


getCenterX

public final float getCenterX()
Computes the xspan of this Box.


getCenterY

public final float getCenterY()
Computes the xspan of this Box.


getCenterZ

public final float getCenterZ()
Computes the xspan of this Box.


getCenter

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

Parameters:
out -

getCenter

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


setMaxSquaredDistance

protected final void setMaxSquaredDistance(float distSq)
Sets the largest distance (squared) from the center


getMaxSquaredDistance

public final float getMaxSquaredDistance()
Returns:
the largest distance (squared) from the center

getMaxDistance

public final float getMaxDistance()
Returns:
the largest distance from the center

setSize

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


setSize

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


getSize

public final void getSize(Tuple3f 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(Body body)
Combines this Body with a bounding object.

Specified by:
combine in interface Body

combine

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

Specified by:
combine in interface Body

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 Body

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 Body

combine

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