public class OrthogonalInterval extends Object
Interval
that additionally stores a y- (in the horizontal case) or x-coordinate (in the
vertical case).
During a PathSearch
, orthogonal intervals are used for specifying the location where an edge enters or exits a
partition cell
.
PathSearch
Constructor and Description |
---|
OrthogonalInterval(double from,
double to,
double location,
boolean isVertical)
|
OrthogonalInterval(Interval range,
double location,
boolean isVertical)
Creates a new
OrthogonalInterval instance with the given interval bounds. |
Modifier and Type | Method and Description |
---|---|
static OrthogonalInterval |
calculateIntersection(OrthogonalInterval i1,
OrthogonalInterval i2)
Calculates the intersection of the given
orthogonal intervals . |
static OrthogonalInterval |
calculateUnion(OrthogonalInterval i1,
OrthogonalInterval i2)
Calculates the union of the given
orthogonal intervals . |
boolean |
coveredBy(OrthogonalInterval other)
Checks whether or not this
orthogonal interval is fully covered by the given
orthogonal interval . |
boolean |
crosses(OrthogonalInterval other)
Determines whether or not this
orthogonal interval crosses the given one. |
double |
distanceTo(OrthogonalInterval other)
|
YPoint |
getCenter()
Gets the center of this
orthogonal interval in the 2D-coordinate system. |
double |
getLocation()
Gets the vertical coordinate for horizontal intervals or the horizontal coordinate for vertical intervals,
respectively.
|
double |
getMax()
Gets the upper bound of the
orthogonal interval . |
double |
getMin()
Gets the lower bound of the
orthogonal interval . |
Interval |
getRange()
Gets the range of this
orthogonal interval . |
double |
getSize()
Gets the length of the
orthogonal interval . |
boolean |
hasSameRange(OrthogonalInterval other)
Checks whether or not this
orthogonal interval and the given orthogonal interval
cover the same range. |
boolean |
intersects(OrthogonalInterval other)
Checks whether or not this
orthogonal interval intersects the given orthogonal interval
and the intersection has a given minimum intersection size. |
boolean |
intersects(OrthogonalInterval other,
double minIntersection)
Checks whether or not this
orthogonal interval intersects the given orthogonal interval
and the intersection has a given minimum intersection size. |
boolean |
isVertical()
Gets whether or not the
orthogonal interval is oriented vertically. |
double |
manhattanDistanceTo(OrthogonalInterval other)
Returns the Manhattan distance of this
orthogonal interval and the given
orthogonal interval . |
String |
toString()
Returns a string representation of this
OrthogonalInterval object. |
public OrthogonalInterval(double from, double to, double location, boolean isVertical)
IllegalArgumentException
- if the given range is null
from
- the start of the interval boundsto
- the end of the interval boundslocation
- the location in the two-dimensional coordinate systemisVertical
- true
if the orthogonal interval is vertical, false
if it is horizontalpublic OrthogonalInterval(Interval range, double location, boolean isVertical)
OrthogonalInterval
instance with the given interval bounds.IllegalArgumentException
- if the given range is null
range
- the given rangelocation
- the location in the two-dimensional coordinate systemisVertical
- true
if the orthogonal interval is vertical, false
if it is horizontalpublic static final OrthogonalInterval calculateIntersection(OrthogonalInterval i1, OrthogonalInterval i2)
orthogonal intervals
.
If the returned orthogonal interval is vertical, it will have the same horizontal location as i2
and the shared
vertical range of both intervals. If it is horizontal, it will have the same vertical location as i2
and the
shared horizontal range of both intervals. The orthogonal intervals must have same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsi1
- the first orthogonal intervali2
- the second orthogonal intervalintersects(OrthogonalInterval, double)
public static final OrthogonalInterval calculateUnion(OrthogonalInterval i1, OrthogonalInterval i2)
orthogonal intervals
.
If the returned orthogonal interval is vertical, it will have the same horizontal location as i2
and the shared
vertical range of both orthogonal intervals. If it is horizontal, it will have the same vertical location as i2
and the shared vertical range of both orthogonal intervals. The orthogonal intervals must have same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsi1
- the first orthogonal intervali2
- the second orthogonal intervalintersects(OrthogonalInterval, double)
public boolean coveredBy(OrthogonalInterval other)
orthogonal interval
is fully covered by the given
orthogonal interval
.
The given orthogonal interval covers this orthogonal interval, if this interval's range is covered by the given interval's range. The location of both orthogonal intervals is ignored. The orthogonal intervals must have the same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsother
- the other orthogonal intervaltrue
if this orthogonal interval is fully covered by the other orthogonal interval, false
otherwisePartitionCell
public boolean crosses(OrthogonalInterval other)
orthogonal interval
crosses the given one.
The orthogonal intervals must have different orientations.
IllegalArgumentException
- if the given orthogonal intervals have the same orientationother
- the other orthogonal intervaltrue
if this orthogonal interval crosses the given one, false
otherwisepublic double distanceTo(OrthogonalInterval other)
ranges
of this orthogonal interval
and the
given orthogonal interval
.
The orthogonal intervals must have the same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsother
- the other orthogonal interval0
if the orthogonal intervals intersect
each other, otherwise
the minimal distance between the orthogonal intervals is returnedpublic YPoint getCenter()
orthogonal interval
in the 2D-coordinate system.public double getLocation()
public double getMax()
orthogonal interval
.public double getMin()
orthogonal interval
.public Interval getRange()
orthogonal interval
.public double getSize()
orthogonal interval
.Interval.getSize()
public boolean hasSameRange(OrthogonalInterval other)
orthogonal interval
and the given orthogonal interval
cover the same range.
If both orthogonal intervals cover the same range, they are considered the same. The location of both orthogonal intervals is ignored. The orthogonal intervals must have the same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsother
- the other orthogonal intervaltrue
if the orthogonal intervals cover the same range, false
otherwisePartitionCell
public final boolean intersects(OrthogonalInterval other)
orthogonal interval
intersects the given orthogonal interval
and the intersection has a given minimum intersection size.
Orthogonal intervals intersect each other, if their ranges intersect each other by at least the given minimum intersection size. The location of both orthogonal intervals is ignored. The orthogonal intervals must have the same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsother
- the other orthogonal intervaltrue
if this interval intersects the given other orthogonal interval, false
otherwisePartitionCell
public boolean intersects(OrthogonalInterval other, double minIntersection)
orthogonal interval
intersects the given orthogonal interval
and the intersection has a given minimum intersection size.
Orthogonal intervals intersect each other, if their ranges intersect each other by at least the given minimum intersection size. The location of both orthogonal intervals is ignored. The orthogonal intervals must have the same orientation.
IllegalArgumentException
- if the orthogonal intervals have different orientationsother
- the other orthogonal intervalminIntersection
- the minimum size of the intersectiontrue
if this interval intersects the given other orthogonal interval, false
otherwisePartitionCell
public boolean isVertical()
orthogonal interval
is oriented vertically.true
if the orthogonal interval is oriented vertically, false
otherwisepublic double manhattanDistanceTo(OrthogonalInterval other)
orthogonal interval
and the given
orthogonal interval
.
If both intervals have the same orientation, the Manhattan distance is the sum of the distance between the intervals' ranges and the distance between the intervals' locations.
If the intervals have different orientations, the Manhattan distance is the sum of the distances between one interval's range and the other interval's location.
other
- the other orthogonal intervalpublic String toString()
OrthogonalInterval
object.toString
in class Object
OrthogonalInterval
object