cz.cuni.amis.pogamut.base.utils.math
Class DistanceUtils

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.math.DistanceUtils

public class DistanceUtils
extends java.lang.Object


Constructor Summary
DistanceUtils()
           
 
Method Summary
static
<T extends ILocated>
T
getNearest(java.util.Collection<T> locations, ILocated target)
          Returns the nearest object to 'target'.
static
<T extends ILocated>
T
getNearest2D(java.util.Collection<T> locations, ILocated target)
          Returns the nearest object to 'target' (ignoring 'z' coordinate).
static
<T extends ILocated>
T
getNearestFiltered(java.util.Collection<T> locations, ILocated target, IFilter<T> filter)
          Returns the nearest object to 'target'.
static
<T extends ILocated>
T
getNearestFiltered2D(java.util.Collection<T> locations, ILocated target, IFilter<T> filter)
          Returns the nearest object to 'target' (ignoring 'z' coordinate).
static
<T extends IViewable>
T
getNearestVisible(java.util.Collection<T> locations, ILocated target)
          Returns the nearest object to 'target'.
static
<T extends IViewable>
T
getNearestVisible2D(java.util.Collection<T> locations, ILocated target)
          Returns the nearest object to 'target' (ignoring 'z' coordinate).
static
<T extends ILocated>
T
getSecondNearest(java.util.Collection<T> locations, ILocated target)
          Returns the second nearest object to 'target'.
static
<T extends ILocated>
T
getSecondNearest2D(java.util.Collection<T> locations, ILocated target)
          Returns the second nearest object to 'target' (ignoring 'z' coordinate).
static
<T extends IViewable>
T
getSecondNearestVisible(java.util.Collection<T> locations, ILocated target)
          Returns the second nearest object to 'target'.
static
<T extends IViewable>
T
getSecondNearestVisible2D(java.util.Collection<T> locations, ILocated target)
          Returns the second nearest object to 'target' (ignoring 'z' coordinate).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistanceUtils

public DistanceUtils()
Method Detail

getNearest

public static <T extends ILocated> T getNearest(java.util.Collection<T> locations,
                                                ILocated target)
Returns the nearest object to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getNearestFiltered

public static <T extends ILocated> T getNearestFiltered(java.util.Collection<T> locations,
                                                        ILocated target,
                                                        IFilter<T> filter)
Returns the nearest object to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getSecondNearest

public static <T extends ILocated> T getSecondNearest(java.util.Collection<T> locations,
                                                      ILocated target)
Returns the second nearest object to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getNearestVisible

public static <T extends IViewable> T getNearestVisible(java.util.Collection<T> locations,
                                                        ILocated target)
Returns the nearest object to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest object from collection of objects

getSecondNearestVisible

public static <T extends IViewable> T getSecondNearestVisible(java.util.Collection<T> locations,
                                                              ILocated target)
Returns the second nearest object to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest object from collection of objects

getNearest2D

public static <T extends ILocated> T getNearest2D(java.util.Collection<T> locations,
                                                  ILocated target)
Returns the nearest object to 'target' (ignoring 'z' coordinate).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getNearestFiltered2D

public static <T extends ILocated> T getNearestFiltered2D(java.util.Collection<T> locations,
                                                          ILocated target,
                                                          IFilter<T> filter)
Returns the nearest object to 'target' (ignoring 'z' coordinate).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getSecondNearest2D

public static <T extends ILocated> T getSecondNearest2D(java.util.Collection<T> locations,
                                                        ILocated target)
Returns the second nearest object to 'target' (ignoring 'z' coordinate).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getNearestVisible2D

public static <T extends IViewable> T getNearestVisible2D(java.util.Collection<T> locations,
                                                          ILocated target)
Returns the nearest object to 'target' (ignoring 'z' coordinate).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest object from collection of objects

getSecondNearestVisible2D

public static <T extends IViewable> T getSecondNearestVisible2D(java.util.Collection<T> locations,
                                                                ILocated target)
Returns the second nearest object to 'target' (ignoring 'z' coordinate).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest object from collection of objects