Struct R1Interval

An R1Interval represents a closed, bounded interval on the real line. It is capable of representing the empty interval (containing no points) and zero-length intervals (containing a single point).

struct R1Interval ;

This class is intended to be copied by value as desired. It uses the default copy constructor and assignment operator.

Constructors

NameDescription
this (lo, hi) Constructor. If lo > hi, the interval is empty.

Methods

NameDescription
addInterval (y) Expands the interval so that it contains the given interval "y".
addPoint (p) Expands the interval so that it contains the given point "p".
approxEquals (y, max_error) Returns true if this interval can be transformed into the given interval by moving each endpoint by at most "max_error". The empty interval is considered to be positioned arbitrarily on the real line, thus any interval with (length <= 2*max_error) matches the empty interval.
contains (y) Returns true if this interval contains the interval 'y'.
empty () Returns an empty interval.
expanded (margin) Returns an interval that has been expanded on each side by the given distance "margin". If "margin" is negative, then shrink the interval on each side by "margin" instead. The resulting interval may be empty. Any expansion of an empty interval remains empty.
fromPoint (p) Convenience method to construct an interval containing a single point.
fromPointPair (p1, p2) 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.
getCenter () Returns the center of the interval. For empty intervals, the result is arbitrary.
getDirectedHausdorffDistance (y) Returns the Hausdorff distance to the given interval 'y'. 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).
getLength () Returns the length of the interval. The length of an empty interval is negative.
interiorContains (y) Returns true if the interior of this interval contains the entire interval 'y' (including its boundary).
interiorIntersects (y) Returns true if the interior of this interval intersects any point of the given interval (including its boundary).
intersection (y) Returns the intersection of this interval with the given interval. Empty intervals do not need to be special-cased.
intersects (y) Returns true if this interval intersects the given interval, i.e. if they have any points in common.
isEmpty () Return true if the interval is empty, i.e. it contains no points.
opEquals (y) Supports the == and != operators. Return true if two intervals contain the same set of points.
opIndex (i) Methods that allow the R1Interval to be accessed as a vector. (The recommended style is to use lo() and hi() whenever possible, but these methods are useful when the endpoint to be selected is not constant.)
project (p) Returns the closest point in the interval to the given point "p". The interval must be
unite (y) Returns the smallest interval that contains this interval and the given interval "y".