Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities
Class HyperBoundingBox

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.HyperBoundingBox
All Implemented Interfaces:
Loggable, Externalizable, Serializable
Direct Known Subclasses:
CASHInterval

public class HyperBoundingBox
extends AbstractLoggable
implements Externalizable

HyperBoundingBox represents a hyperrectangle in the multidimensional space.

Author:
Elke Achtert
See Also:
Serialized Form

Field Summary
private  double[] max
          The coordinates of the 'upper right' (= maximum) hyper point.
private  double[] min
          The coordinates of the 'lower left' (= minimum) hyper point.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
HyperBoundingBox()
          Empty constructor for Externalizable interface.
HyperBoundingBox(double[] min, double[] max)
          Creates a HyperBoundingBox for the given hyper points.
 
Method Summary
 double[] centroid()
          Returns the centroid of this HyperBoundingBox.
 double[] centroid(int start, int end)
          Returns the centroid of the specified values of this HyperBoundingBox.
 boolean contains(double[] point)
          Returns true if this HyperBoundingBox contains the given point, false otherwise.
 boolean contains(HyperBoundingBox box)
          Returns true if this HyperBoundingBox contains the given HyperBoundingBox, false otherwise.
 boolean equals(Object obj)
           
 int getDimensionality()
          Returns the dimensionality of this HyperBoundingBox.
 double[] getMax()
          Returns a clone of the maximum hyper point.
 double getMax(int dimension)
          Returns the coordinate at the specified dimension of the maximum hyper point
 double[] getMin()
          Returns a clone of the minimum hyper point.
 double getMin(int dimension)
          Returns the coordinate at the specified dimension of the minimum hyper point
 int hashCode()
           
 boolean intersects(HyperBoundingBox box)
          Returns true if this HyperBoundingBox and the given HyperBoundingBox intersect, false otherwise.
 double overlap(HyperBoundingBox box)
          Computes the volume of the overlapping box between this HyperBoundingBox and the given HyperBoundingBox and return the relation between the volume of the overlapping box and the volume of both HyperBoundingBoxes.
 double perimeter()
          Computes the perimeter of this HyperBoundingBox.
 void readExternal(ObjectInput in)
          The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
 String toString()
          Retuns a String representation of the HyperBoundingBox.
 String toString(String pre, NumberFormat nf)
          Retuns a String representation of the HyperBoundingBox.
 HyperBoundingBox union(HyperBoundingBox box)
          Computes the union HyperBoundingBox of this HyperBoundingBox and the given HyperBoundingBox.
 double volume()
          Computes the volume of this HyperBoundingBox
 void writeExternal(ObjectOutput out)
          The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

min

private double[] min
The coordinates of the 'lower left' (= minimum) hyper point.


max

private double[] max
The coordinates of the 'upper right' (= maximum) hyper point.

Constructor Detail

HyperBoundingBox

public HyperBoundingBox()
Empty constructor for Externalizable interface.


HyperBoundingBox

public HyperBoundingBox(double[] min,
                        double[] max)
Creates a HyperBoundingBox for the given hyper points.

Parameters:
min - - the coordinates of the minimum hyper point
max - - the coordinates of the maximum hyper point
Method Detail

getMin

public double[] getMin()
Returns a clone of the minimum hyper point.

Returns:
the minimum hyper point

getMin

public double getMin(int dimension)
Returns the coordinate at the specified dimension of the minimum hyper point

Parameters:
dimension - the dimension for which the coordinate should be returned, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the coordinate at the specified dimension of the minimum hyper point

getMax

public double[] getMax()
Returns a clone of the maximum hyper point.

Returns:
the maximum hyper point

getMax

public double getMax(int dimension)
Returns the coordinate at the specified dimension of the maximum hyper point

Parameters:
dimension - the dimension for which the coordinate should be returned, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the coordinate at the specified dimension of the maximum hyper point

getDimensionality

public int getDimensionality()
Returns the dimensionality of this HyperBoundingBox.

Returns:
the dimensionality of this HyperBoundingBox

intersects

public boolean intersects(HyperBoundingBox box)
Returns true if this HyperBoundingBox and the given HyperBoundingBox intersect, false otherwise.

Parameters:
box - the HyperBoundingBox to be tested for intersection
Returns:
true if this HyperBoundingBox and the given HyperBoundingBox intersect, false otherwise

contains

public boolean contains(HyperBoundingBox box)
Returns true if this HyperBoundingBox contains the given HyperBoundingBox, false otherwise.

Parameters:
box - the HyperBoundingBox to be tested for containment
Returns:
true if this HyperBoundingBox contains the given HyperBoundingBox, false otherwise

contains

public boolean contains(double[] point)
Returns true if this HyperBoundingBox contains the given point, false otherwise.

Parameters:
point - the point to be tested for containment
Returns:
true if this HyperBoundingBox contains the given point, false otherwise

volume

public double volume()
Computes the volume of this HyperBoundingBox

Returns:
the volume of this HyperBoundingBox

perimeter

public double perimeter()
Computes the perimeter of this HyperBoundingBox.

Returns:
the perimeter of this HyperBoundingBox

overlap

public double overlap(HyperBoundingBox box)
Computes the volume of the overlapping box between this HyperBoundingBox and the given HyperBoundingBox and return the relation between the volume of the overlapping box and the volume of both HyperBoundingBoxes.

Parameters:
box - the HyperBoundingBox for which the intersection volume with this HyperBoundingBox should be computed
Returns:
the relation between the volume of the overlapping box and the volume of this HyperBoundingBox and the given HyperBoundingBox

union

public HyperBoundingBox union(HyperBoundingBox box)
Computes the union HyperBoundingBox of this HyperBoundingBox and the given HyperBoundingBox.

Parameters:
box - the HyperBoundingBox to be united with this HyperBoundingBox
Returns:
the union HyperBoundingBox of this HyperBoundingBox and the given HyperBoundingBox

centroid

public double[] centroid()
Returns the centroid of this HyperBoundingBox.

Returns:
the centroid of this HyperBoundingBox

centroid

public double[] centroid(int start,
                         int end)
Returns the centroid of the specified values of this HyperBoundingBox.

Parameters:
start - the start dimension to be considered
end - the end dimension to be considered
Returns:
the centroid of the specified values of this HyperBoundingBox

toString

public String toString()
Retuns a String representation of the HyperBoundingBox.

Overrides:
toString in class Object
Returns:
a string representation of this hyper bounding box

toString

public String toString(String pre,
                       NumberFormat nf)
Retuns a String representation of the HyperBoundingBox.

Parameters:
nf - number format for output accuracy
pre - the prefix of each line
Returns:
a string representation of this hyper bounding box

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - the stream to write the object to
Throws:
IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Specified by:
readExternal in interface Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being restored cannot be found.

Release 0.1 (2008-07-10_1838)