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).

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

Constructors

this
this(double lo, double hi)

Constructor. If lo > hi, the interval is empty.

Members

Functions

addInterval
void addInterval(R1Interval y)

Expands the interval so that it contains the given interval "y".

addPoint
void addPoint(double p)

Expands the interval so that it contains the given point "p".

approxEquals
bool approxEquals(R1Interval y, double 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.

bounds
Vector2_d bounds()
Undocumented in source. Be warned that the author may not have intended to support it.
contains
bool contains(double p)
Undocumented in source. Be warned that the author may not have intended to support it.
contains
bool contains(R1Interval y)

Returns true if this interval contains the interval 'y'.

expanded
R1Interval expanded(double 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.

getCenter
double getCenter()

Returns the center of the interval. For empty intervals, the result is arbitrary.

getDirectedHausdorffDistance
double getDirectedHausdorffDistance(R1Interval 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
double getLength()

Returns the length of the interval. The length of an empty interval is negative.

interiorContains
bool interiorContains(double p)
Undocumented in source. Be warned that the author may not have intended to support it.
interiorContains
bool interiorContains(R1Interval y)

Returns true if the interior of this interval contains the entire interval 'y' (including its boundary).

interiorIntersects
bool interiorIntersects(R1Interval y)

Returns true if the interior of this interval intersects any point of the given interval (including its boundary).

intersection
R1Interval intersection(R1Interval y)

Returns the intersection of this interval with the given interval. Empty intervals do not need to be special-cased.

intersects
bool intersects(R1Interval y)

Returns true if this interval intersects the given interval, i.e. if they have any points in common.

isEmpty
bool isEmpty()

Return true if the interval is empty, i.e. it contains no points.

mutableBounds
Vector2_d mutableBounds()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(R1Interval y)

Supports the == and != operators. Return true if two intervals contain the same set of points.

opIndex
inout(double) opIndex(size_t 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.)

opIndexAssign
void opIndexAssign(double v, size_t i)
Undocumented in source. Be warned that the author may not have intended to support it.
project
double project(double p)

Returns the closest point in the interval to the given point "p". The interval must be

setHi
void setHi(double p)
Undocumented in source. Be warned that the author may not have intended to support it.
setLo
void setLo(double p)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
unite
R1Interval unite(R1Interval y)

Returns the smallest interval that contains this interval and the given interval "y".

Properties

hi
double hi [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
lo
double lo [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

empty
R1Interval empty()

Returns an empty interval.

fromPoint
R1Interval fromPoint(double p)

Convenience method to construct an interval containing a single point.

fromPointPair
R1Interval fromPointPair(double p1, double 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.

Meta