public final class PointDComparatorY extends PointDComparator
PointD
instances, preferring PointD.y
coordinates.
Defines a lexicographic ordering for PointD
instances, sorting first by
PointD.y
and then by PointD.x
coordinates. Use PointDComparatorX
to sort first by PointD.x
coordinates.
Coordinate comparisons may be performed precisely or with a specified epsilon. The actual comparisons are performed by two static methods, so you need to instantiate this class only when required by a consumer.
epsilon
Constructor and Description |
---|
PointDComparatorY()
Creates a
PointDComparatorY with an epsilon of zero. |
PointDComparatorY(double epsilon)
Creates a
PointDComparatorY with the specified epsilon. |
Modifier and Type | Method and Description |
---|---|
int |
compare(PointD a,
PointD b)
Compares two specified
PointD instances and returns an indication of their
lexicographic ordering, given the current epsilon for coordinate comparisons. |
int |
compareEpsilon(PointD a,
PointD b)
Compares two specified
PointD instances and returns an indication of their
lexicographic ordering, given the current epsilon for coordinate comparisons. |
static int |
compareEpsilon(PointD a,
PointD b,
double epsilon)
Compares two specified
PointD instances and returns an indication of their
lexicographic ordering, given the specified epsilon for coordinate comparisons. |
static int |
compareExact(PointD a,
PointD b)
Compares two specified
PointD instances and returns an indication of their
lexicographic ordering, using exact coordinate comparisons. |
protected double |
getPrimary(PointD point)
Gets the primary dimension of the specified
PointD . |
protected double |
getSecondary(PointD point)
Gets the secondary dimension of the specified
PointD . |
findNearest, findNearest, findRange, findRange
public PointDComparatorY()
PointDComparatorY
with an epsilon of zero.public PointDComparatorY(double epsilon)
PointDComparatorY
with the specified epsilon.epsilon
- the maximum absolute difference at which coordinates should be considered equaljava.lang.IllegalArgumentException
- if epsilon
is less than zeropublic int compare(PointD a, PointD b)
PointD
instances and returns an indication of their
lexicographic ordering, given the current epsilon for coordinate comparisons.
Dispatches to compareExact(org.kynosarges.tektosyne.geometry.PointD, org.kynosarges.tektosyne.geometry.PointD)
if epsilon is zero, else to compareEpsilon(org.kynosarges.tektosyne.geometry.PointD, org.kynosarges.tektosyne.geometry.PointD)
.public int compareEpsilon(PointD a, PointD b)
PointD
instances and returns an indication of their
lexicographic ordering, given the current epsilon for coordinate comparisons.
Slightly faster than compare(org.kynosarges.tektosyne.geometry.PointD, org.kynosarges.tektosyne.geometry.PointD)
if the current epsilon is known to be positive.public static int compareEpsilon(PointD a, PointD b, double epsilon)
PointD
instances and returns an indication of their
lexicographic ordering, given the specified epsilon for coordinate comparisons.
Uses MathUtils.compare(double, double, double)
for comparisons.a
- the first PointD
to compareb
- the second PointD
to compareepsilon
- the maximum absolute difference where coordinates are considered equala
compares less than,
equal to, or greater than b
, respectively, given the specified epsilon
java.lang.IllegalArgumentException
- if epsilon
is less than zerojava.lang.NullPointerException
- if a
or b
is null
public static int compareExact(PointD a, PointD b)
PointD
instances and returns an indication of their
lexicographic ordering, using exact coordinate comparisons.protected double getPrimary(PointD point)
PointD
.getPrimary
in class PointDComparator
point
- the PointD
whose primary dimension to returnPointD.y
component of point
java.lang.NullPointerException
- if point
is null
protected double getSecondary(PointD point)
PointD
.getSecondary
in class PointDComparator
point
- the PointD
whose secondary dimension to returnPointD.x
component of point
java.lang.NullPointerException
- if point
is null