ApproxEqual reports whether this interval can be transformed into the given interval by moving each endpoint by at most ε, without the endpoints crossing (which would invert the interval). Empty and full intervals are considered to start at an arbitrary point on the unit circle, so any interval with (length <= 2ε) matches the empty interval, and any interval with (length >= 2π - 2*ε) matches the full interval.
Returns the midpoint of the interval. It is undefined for full and empty intervals.
Complement returns the complement of the interior of the interval. An interval and its complement have the same boundary but do not share any interior values. The complement operator is not a bijection, since the complement of a singleton interval (containing a single value) is the same as the complement of an empty interval.
ComplementCenter returns the midpoint of the complement of the interval. For full and empty intervals, the result is arbitrary. For a singleton interval (containing a single point), the result is its antipodal point on S1.
Returns true iff the interval contains p. Assumes p ∈ [-π,π].
Expanded returns an interval that has been expanded on each side by margin. If margin is negative, then the function shrinks the interval on each side by margin instead. The resulting interval may be empty or full. Any expansion (positive or negative) of a full interval remains full, and any expansion of an empty interval remains empty.
Assumes p ∈ (-π,π].
Returns true iff the interior of the interval contains p. Assumes p ∈ [-π,π].
Reports whether the interval is empty.
Reports whether the interval is full.
Reports whether the interval is inverted; that is, whether lo > hi.
Reports whether the interval is valid.
Returns the length of the interval. The length of an empty interval is negative.
Project returns the closest point in the interval to the given point p. The interval must be non-empty.
Static
positiveCompute distance from a to b in [0,2π], in a numerically stable way.
An Interval represents a closed interval on a unit circle (also known as a 1-dimensional sphere). It is capable of representing the empty interval (containing no points), the full interval (containing all points), and zero-length intervals (containing a single point).
Points are represented by the angle they make with the positive x-axis in the range [-π, π]. An interval is represented by its lower and upper bounds (both inclusive, since the interval is closed). The lower bound may be greater than the upper bound, in which case the interval is "inverted" (i.e. it passes through the point (-1, 0)).
The point (-1, 0) has two valid representations, π and -π. The normalized representation of this point is π, so that endpoints of normal intervals are in the range (-π, π]. We normalize the latter to the former in intervalFromEndpoints. However, we take advantage of the point -π to construct two special intervals:
The full interval is [-π, π] The empty interval is [π, -π].
Treat the exported fields as read-only.