C

Interval

This class represents a one-dimensional closed interval.
Inheritance Hierarchy

Members

No filters for this type

Constructors

Creates a new Interval between the given bounds.
The upper and lower bound of the two given values are determined automatically, i.e., the smaller one will be treated as the lower bound and the larger one as the upper bound.

Parameters

bound1: number
the first interval bound
bound2: number
the second interval bound

Properties

Gets the midpoint of the interval.
readonlyfinal

Property Value

the midpoint of the interval
Gets the upper bound of the interval.
readonlyfinal

Property Value

the upper bound of the interval
Gets the lower bound of the interval.
readonlyfinal

Property Value

the lower bound of the interval
Gets the size of the interval, i.e., the difference between the upper bound and the lower bound.
readonlyfinal

Property Value

the size of the interval

Methods

Checks whether or not the given value lies within the interval.
final

Parameters

value: number
the value to check

Return Value

boolean
true if the value lies within the interval, false otherwise
Checks whether or not the given Interval fully covers this Interval given a small epsilon value.
The given interval covers this interval, if other lower bound - epsilon <= this lower bound and this upper bound <= other upper bound + epsilon.
final

Parameters

other: Interval
the other interval
eps?: number
the epsilon value that determines the extended range of the other interval

Return Value

boolean
true if this interval is fully covered by the other interval, false otherwise
Returns the distance between the value and this Interval.
If this interval contains the specified value, the distance is 0. Otherwise, it is the minimum of dist(value, lower bound) and dist(value, upper bound).
final

Parameters

value: number
The value to which the distance is calculated

Return Value

number
The distance between the value and the interval
Returns the distance between this Interval and the given Interval.
If the intervals intersect, the distance is 0. Otherwise, it is equal to dist(minimum of upper bounds, maximum of lower bounds).
final

Parameters

other: Interval
the other interval to which the distance is calculated

Return Value

number
the distance between this interval and the given interval
Checks whether or not this Interval equals the given Interval.
Two intervals are equal if they have the same lower and upper bounds.
final

Parameters

other: any
the other interval

Return Value

boolean
true if the two given intervals are equal, false otherwise
Returns the Interval bound that is closest to the given value.
final

Parameters

value: number
The value for which the closest interval bound will be returned

Return Value

number
  • The value, if the given value lies within the interval, or
  • The lower bound, if the given value is smaller than or equal to the lower bound, or
  • The upper bound, if the given value is greater than or equal to the upper bound
Returns the hash code for this Interval.
final

Return Value

number
the hash code for this interval
Checks whether or not this Interval and the given Interval cover the same range.
The intervals are considered to cover the same range, if their minimum values as well as their maximum values differ only by the given epsilon value.
final

Parameters

other: Interval
the other interval
eps?: number
the maximum distance between the two minimum and the two maximum values

Return Value

boolean
true if the intervals cover the same range, false otherwise
Checks whether or not this Interval intersects with the given Interval, considering the given minimum intersection length.
final

Parameters

other: Interval
the other interval to check
minIntersection?: number
the minimum length of the intersection of the intervals

Return Value

boolean
true if the intervals intersect at least by the given minimum length, false otherwise
Checks whether or not the lower bound of this Interval is greater than the upper bound of the given interval.
final

Parameters

other: Interval
the interval to compare

Return Value

boolean
true if the current interval is on the right of the given one, false otherwise
Checks whether or not the upper bound of this Interval is smaller than the lower bound of the given interval.
final

Parameters

other: Interval
the interval to compare

Return Value

boolean
true if the current interval is on the left of the given one, false otherwise
Returns a string representation of this Interval object.
final

Return Value

string
A string representation of this Interval object.

Static Methods

Returns the bridging Interval between the given Intervals.
The bridging interval is null if the given intervals intersect each other. Otherwise, the bridging interval is [minimum of upper bounds, maximum of lower bounds].
static

Parameters

i1: Interval
the first interval
i2: Interval
the second interval

Return Value

Interval
the bridging interval between the given intervals or null if the intervals intersect
Returns the intersection of the given Intervals.
The intersection is null if the given intervals do not intersect each other. Otherwise, the intersection is [maximum of lower bounds, minimum of upper bounds].
static

Parameters

i1: Interval
the first interval
i2: Interval
the second interval

Return Value

Interval
the intersection of the given intervals or null if the intervals do not intersect
Returns the spanning rectangle between the given Intervals.
The first interval spans the rectangle in horizontal dimension, the second interval in vertical dimension.
static

Parameters

horizontal: Interval
the interval that defines the location and length of the rectangle in horizontal dimension
vertical: Interval
the interval that defines the location and length of the rectangle in vertical dimension

Return Value

Rect
the spanning rectangle between the given intervals
Returns the union of the given Intervals.
The union is [minimum of lower bounds, maximum of upper bounds].
static

Parameters

i1: Interval
the first interval
i2: Interval
the second interval

Return Value

Interval
the union of the given intervals
Returns the union of the given Intervals and the given value.
The union is between the minimum of the lower bound of the given interval and the given value and the maximum of the upper bound of the given interval and the given value.
static

Parameters

interval: Interval
the interval to be extended
value: number
the value to be in the union

Return Value

Interval
the union of the given interval and the given value