Package elki.data.spatial
Class SpatialUtil
- java.lang.Object
-
- elki.data.spatial.SpatialUtil
-
public final class SpatialUtil extends java.lang.Object
Utility class with spatial functions.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SpatialUtil()
Fake constructor: do not instantiate.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
assertSameDimensionality(SpatialComparable box1, SpatialComparable box2)
Check that two spatial objects have the same dimensionality.static double[]
centroid(SpatialComparable obj)
Returns the centroid of this SpatialComparable.static boolean
contains(SpatialComparable box, double[] point)
Returns true if this SpatialComparable contains the given point, false otherwise.static boolean
contains(SpatialComparable box1, SpatialComparable box2)
Returns true if the first SpatialComparable contains the second SpatialComparable, false otherwise.static double
enlargement(SpatialComparable exist, SpatialComparable addit)
Compute the enlargement obtained by adding an object to an existing object.static boolean
equals(SpatialComparable box1, SpatialComparable box2)
Test two SpatialComparables for equality.static double[]
getMax(SpatialComparable box)
Returns a clone of the maximum hyper point.static double[]
getMin(SpatialComparable box)
Returns a clone of the minimum hyper point.static ModifiableHyperBoundingBox
intersection(SpatialComparable box1, SpatialComparable box2)
Calculate the intersection of the two MBRs ornull
if they do not intersect.static boolean
intersects(SpatialComparable box1, SpatialComparable box2)
Returns true if the two SpatialComparables intersect, false otherwise.static double
overlap(SpatialComparable box1, SpatialComparable box2)
Computes the volume of the overlapping box between two SpatialComparables.static double
perimeter(SpatialComparable box)
Computes the perimeter of this SpatialComparable.static double
relativeOverlap(SpatialComparable box1, SpatialComparable box2)
Computes the volume of the overlapping box between two SpatialComparables and return the relation between the volume of the overlapping box and the volume of both SpatialComparable.static ModifiableHyperBoundingBox
union(SpatialComparable box1, SpatialComparable box2)
Computes the union HyperBoundingBox of two SpatialComparables.static ModifiableHyperBoundingBox
unionTolerant(SpatialComparable mbr1, SpatialComparable mbr2)
Returns the union of the two specified MBRs.static double
volume(SpatialComparable box)
Computes the volume of this SpatialComparable.static double
volumeScaled(SpatialComparable box, double scale)
Computes the volume of this SpatialComparable.static double
volumeUnion(SpatialComparable box1, SpatialComparable box2)
Compute the volume (area) of the union of two MBRs.static double
volumeUnionScaled(SpatialComparable box1, SpatialComparable box2, double scale)
Compute the volume (area) of the union of two MBRs.
-
-
-
Method Detail
-
assertSameDimensionality
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2)
Check that two spatial objects have the same dimensionality.- Parameters:
box1
- First objectbox2
- Second object- Returns:
- Dimensionality
- Throws:
java.lang.IllegalArgumentException
- when the dimensionalities do not agree
-
getMin
public static double[] getMin(SpatialComparable box)
Returns a clone of the minimum hyper point.- Parameters:
box
- spatial object- Returns:
- the minimum hyper point
-
getMax
public static double[] getMax(SpatialComparable box)
Returns a clone of the maximum hyper point.- Parameters:
box
- spatial object- Returns:
- the maximum hyper point
-
intersects
public static boolean intersects(SpatialComparable box1, SpatialComparable box2)
Returns true if the two SpatialComparables intersect, false otherwise.- Parameters:
box1
- the first SpatialComparablebox2
- the first SpatialComparable- Returns:
- true if the SpatialComparables intersect, false otherwise
-
contains
public static boolean contains(SpatialComparable box1, SpatialComparable box2)
Returns true if the first SpatialComparable contains the second SpatialComparable, false otherwise.- Parameters:
box1
- the outer SpatialComparablebox2
- the inner SpatialComparable- Returns:
- true if the first SpatialComparable contains the second SpatialComparable, false otherwise
-
contains
public static boolean contains(SpatialComparable box, double[] point)
Returns true if this SpatialComparable contains the given point, false otherwise.- Parameters:
box
- spatial objectpoint
- the point to be tested for containment- Returns:
- true if this SpatialComparable contains the given point, false otherwise
-
volume
public static double volume(SpatialComparable box)
Computes the volume of this SpatialComparable.- Parameters:
box
- Spatial object- Returns:
- the volume of this SpatialComparable
-
volumeUnion
public static double volumeUnion(SpatialComparable box1, SpatialComparable box2)
Compute the volume (area) of the union of two MBRs.- Parameters:
box1
- First objectbox2
- Second object- Returns:
- Volume of union
-
volumeScaled
public static double volumeScaled(SpatialComparable box, double scale)
Computes the volume of this SpatialComparable.- Parameters:
box
- Boxscale
- Scaling factor- Returns:
- the volume of this SpatialComparable
-
volumeUnionScaled
public static double volumeUnionScaled(SpatialComparable box1, SpatialComparable box2, double scale)
Compute the volume (area) of the union of two MBRs.- Parameters:
box1
- First objectbox2
- Second objectscale
- Scaling factor- Returns:
- Volume of union
-
enlargement
public static double enlargement(SpatialComparable exist, SpatialComparable addit)
Compute the enlargement obtained by adding an object to an existing object.- Parameters:
exist
- Existing rectangleaddit
- Additional rectangle- Returns:
- Enlargement factor
-
perimeter
public static double perimeter(SpatialComparable box)
Computes the perimeter of this SpatialComparable.- Parameters:
box
- spatial object- Returns:
- the perimeter of this SpatialComparable
-
overlap
public static double overlap(SpatialComparable box1, SpatialComparable box2)
Computes the volume of the overlapping box between two SpatialComparables.- Parameters:
box1
- the first SpatialComparablebox2
- the second SpatialComparable- Returns:
- the overlap volume.
-
relativeOverlap
public static double relativeOverlap(SpatialComparable box1, SpatialComparable box2)
Computes the volume of the overlapping box between two SpatialComparables and return the relation between the volume of the overlapping box and the volume of both SpatialComparable.- Parameters:
box1
- the first SpatialComparablebox2
- the second SpatialComparable- Returns:
- the overlap volume in relation to the singular volumes.
-
union
public static ModifiableHyperBoundingBox union(SpatialComparable box1, SpatialComparable box2)
Computes the union HyperBoundingBox of two SpatialComparables.- Parameters:
box1
- the first SpatialComparablebox2
- the second SpatialComparable- Returns:
- the union HyperBoundingBox of this HyperBoundingBox and the given HyperBoundingBox
-
unionTolerant
public static ModifiableHyperBoundingBox unionTolerant(SpatialComparable mbr1, SpatialComparable mbr2)
Returns the union of the two specified MBRs. Tolerant of "null" values.- Parameters:
mbr1
- the first MBRmbr2
- the second MBR- Returns:
- the union of the two specified MBRs
-
intersection
public static ModifiableHyperBoundingBox intersection(SpatialComparable box1, SpatialComparable box2)
Calculate the intersection of the two MBRs ornull
if they do not intersect. Note: if the given MBRs intersect in only one point of any dimension, this method still returns a result!- Parameters:
box1
- the first MBRbox2
- the second MBR- Returns:
- the union of the two specified MBRs
-
centroid
public static double[] centroid(SpatialComparable obj)
Returns the centroid of this SpatialComparable.- Parameters:
obj
- Spatial object to process- Returns:
- the centroid of this SpatialComparable
-
equals
public static boolean equals(SpatialComparable box1, SpatialComparable box2)
Test two SpatialComparables for equality.- Parameters:
box1
- First bounding boxbox2
- Second bounding box- Returns:
- true when the boxes are equal
-
-