ru.sscc.util
Class BoundingBox

java.lang.Object
  |
  +--ru.sscc.util.BoundingBox

public class BoundingBox
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Provides the calculation of minimal bounding box around of a set of vectors in multidimensional space.

See Also:
Serialized Form

Field Summary
 int dimension
          A dimension of vector space.
 
Constructor Summary
BoundingBox(int dimension)
          Constructor.
 
Method Summary
 java.lang.Object clone()
          Clones the bounding box.
 boolean contains(double[] vector, int position)
          Tests the bounding box to contain a vector specified.
 boolean contains(float[] vector, int position)
          Tests the bounding box to contain a vector specified.
 boolean contains(RealPointer vector)
          Tests the bounding box to contain a vector specified.
 void enlargeBy(double[] vector, int position)
          Enlarges the bounding box to contain a vector specified.
 void enlargeBy(float[] vector, int position)
          Enlarges the bounding box to contain a vector specified.
 void enlargeBy(RealPointer vector)
          Enlarges the bounding box to contain a vector specified.
 RealPointer getLowerCorner()
          Returns the lower corner of the bounding box or null for empty bounding box.
 RealPointer getUpperCorner()
          Returns the upper corner of the bounding box or null for empty bounding box.
 boolean isEmpty()
          Tests the bounding box to be an empty set.
 double width(int i)
          Return the width of the bounding box in i-th direction or 0 for empty bounding box.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dimension

public final int dimension
A dimension of vector space.
Constructor Detail

BoundingBox

public BoundingBox(int dimension)
Constructor.
Parameters:
dimension - a dimension of vector space
Method Detail

enlargeBy

public void enlargeBy(double[] vector,
                      int position)
Enlarges the bounding box to contain a vector specified.
Parameters:
vector - an array containing the vector
position - a starting position of the vector in the array

enlargeBy

public void enlargeBy(float[] vector,
                      int position)
Enlarges the bounding box to contain a vector specified.
Parameters:
vector - an array containing the vector
position - a starting position of the vector in the array

enlargeBy

public void enlargeBy(RealPointer vector)
Enlarges the bounding box to contain a vector specified.
Parameters:
vector - a pointer to the vector

contains

public boolean contains(double[] vector,
                        int position)
Tests the bounding box to contain a vector specified.
Parameters:
vector - an array containing the vector
position - a starting position of the vector in the array
Returns:
true if the vector belongs to the box

contains

public boolean contains(float[] vector,
                        int position)
Tests the bounding box to contain a vector specified.
Parameters:
vector - an array containing the vector
position - a starting position of the vector in the array
Returns:
true if the vector belongs to the box

contains

public boolean contains(RealPointer vector)
Tests the bounding box to contain a vector specified.
Parameters:
vector - a pointer to the vector
Returns:
true if the vector belongs to the box

isEmpty

public final boolean isEmpty()
Tests the bounding box to be an empty set.

getLowerCorner

public RealPointer getLowerCorner()
Returns the lower corner of the bounding box or null for empty bounding box.

getUpperCorner

public RealPointer getUpperCorner()
Returns the upper corner of the bounding box or null for empty bounding box.

width

public double width(int i)
Return the width of the bounding box in i-th direction or 0 for empty bounding box.

clone

public java.lang.Object clone()
Clones the bounding box.
Overrides:
clone in class java.lang.Object
Returns:
clone of this box