Class R1Interval
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumDesignates which end of the interval to work with. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, contains the empty interval.R1Interval(double lo, double hi) Interval constructor.R1Interval(R1Interval interval) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddPoint(double p) Returns the smallest interval that contains this interval and the pointp.booleanAsapproxEquals(R1Interval, double), with a default value for maxError just larger than typical rounding errors in computing intervals.booleanapproxEquals(R1Interval y, double maxError) Returns true if this interval can be transformed intoyby moving each endpoint by at mostmaxError.doubleclampPoint(double p) Returns the closest point in the interval to the pointp.booleancontains(double p) booleanReturns true if this interval contains the intervaly.static R1Intervalempty()Returns an empty interval.booleanexpanded(double radius) Return an interval that contains all points with a distance "radius" of a point in this interval.(package private) voidexpandedInternal(double radius) Expands this interval to contain all points within a distance "radius" of a point in this interval.static R1IntervalfromPoint(double p) Convenience method to construct an interval containing a single point.static R1IntervalfromPointPair(double p1, double p2) Convenience method to construct the minimal interval containing the two given points.doubleReturns the center of the interval.doubleReturn the Hausdorff distance to the given intervaly.doubleReturns the length of the interval.(package private) doublegetValue(R1Interval.Endpoint endpoint) Returns the value at the given Endpoint, which must not be null.inthashCode()doublehi()(package private) voidinitFromPointPair(double p1, double p2) booleaninteriorContains(double p) booleanReturns true if the interior of this interval contains the entire intervaly(including its boundary).booleanReturns true if the interior of this interval intersects any point ofy(including its boundary).Returns the intersection of this interval withy.(package private) voidSets this interval to the intersection of the current interval andy.booleanReturns true if this interval intersectsy, i.e.booleanisEmpty()Returns true if the interval is empty, i.e.doublelo()(package private) voidset(double lo, double hi) Sets the minimum and maximum value of this interval.(package private) voidsetEmpty()Sets the current interval to the empty interval.(package private) voidsetHi(double hi) Sets the maximum value of this interval.(package private) voidsetLo(double lo) Sets the minimum value of this interval.(package private) voidsetValue(R1Interval.Endpoint endpoint, double value) Sets the value of the given Endpoint, which must not be null.toString()union(R1Interval y) Returns the smallest interval that contains this interval andy.(package private) voidunionInternal(double p) Expands this interval so that it contains the pointp.(package private) voidSets this interval to the union of this interval andy.
-
Field Details
-
lo
private double lo -
hi
private double hi
-
-
Constructor Details
-
R1Interval
R1Interval()Default constructor, contains the empty interval.Package private since only the S2 library needs to mutate R1Intervals. External code that needs an empty interval should call
empty(). -
R1Interval
public R1Interval(double lo, double hi) Interval constructor. If lo > hi, the interval is empty. -
R1Interval
Copy constructor.
-
-
Method Details
-
empty
Returns an empty interval. (Any interval where lo > hi is considered empty.) -
fromPoint
Convenience method to construct an interval containing a single point. -
fromPointPair
Convenience method to construct the minimal interval containing the two given points. This is equivalent to starting with an empty interval and calling AddPoint() twice, but it is more efficient. -
initFromPointPair
void initFromPointPair(double p1, double p2) -
lo
public double lo() -
hi
public double hi() -
getValue
Returns the value at the given Endpoint, which must not be null. -
setValue
Sets the value of the given Endpoint, which must not be null. -
isEmpty
public boolean isEmpty()Returns true if the interval is empty, i.e. it contains no points. -
getCenter
public double getCenter()Returns the center of the interval. For empty intervals, the result is arbitrary. -
getLength
public double getLength()Returns the length of the interval. The length of an empty interval is negative. -
contains
public boolean contains(double p) -
interiorContains
public boolean interiorContains(double p) -
contains
Returns true if this interval contains the intervaly. -
interiorContains
Returns true if the interior of this interval contains the entire intervaly(including its boundary). -
intersects
Returns true if this interval intersectsy, i.e. if they have any points in common. -
interiorIntersects
Returns true if the interior of this interval intersects any point ofy(including its boundary). -
getDirectedHausdorffDistance
Return the Hausdorff distance to the given intervaly. For two R1Intervals x and y, this distance is defined as h(x, y) = max_{p in x} min_{q in y} d(p, q). -
set
void set(double lo, double hi) Sets the minimum and maximum value of this interval. Iflois greater thanhithis interval will become empty.Package private since only the S2 libraries have a current need to mutate R1Intervals.
-
setLo
void setLo(double lo) Sets the minimum value of this interval. Iflois greater thanhi()this interval will become empty.Package private since only the S2 libraries have a current need to mutate R1Intervals.
-
setHi
void setHi(double hi) Sets the maximum value of this interval. Ifhiis less thanlo()this interval will become empty.Package private since only the S2 libraries have a current need to mutate R1Intervals.
-
setEmpty
void setEmpty()Sets the current interval to the empty interval.Package private since only the S2 libraries have a current need to mutate R1Intervals.
-
unionInternal
void unionInternal(double p) Expands this interval so that it contains the pointp.Package private since only the S2 library needs to mutate R1Intervals.
-
clampPoint
public double clampPoint(double p) Returns the closest point in the interval to the pointp. The interval must be non-empty. -
expanded
Return an interval that contains all points with a distance "radius" of a point in this interval. Note that the expansion of an empty interval is always empty. -
expandedInternal
void expandedInternal(double radius) Expands this interval to contain all points within a distance "radius" of a point in this interval.Package private since only S2 classes are intended to mutate R1Intervals for now.
-
union
Returns the smallest interval that contains this interval andy. -
unionInternal
Sets this interval to the union of this interval andy.Package private since only S2 classes are intended to mutate R11Intervals for now.
-
intersection
Returns the intersection of this interval withy. Empty intervals do not need to be special-cased. -
intersectionInternal
Sets this interval to the intersection of the current interval andy.Package private since only S2 classes are intended to mutate R1 intervals for now.
-
addPoint
Returns the smallest interval that contains this interval and the pointp. -
equals
-
hashCode
public int hashCode() -
approxEquals
AsapproxEquals(R1Interval, double), with a default value for maxError just larger than typical rounding errors in computing intervals. -
approxEquals
Returns true if this interval can be transformed intoyby moving each endpoint by at mostmaxError. The empty interval is considered to be positioned arbitrarily on the real line, thus any interval for whichlength <= 2*maxErroris true matches the empty interval. -
toString
-