s2js
    Preparing search index...

    Class Interval

    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.

    Index

    Constructors

    • Constructs a new interval from endpoints. Both arguments must be in the range [-π,π]. This function allows inverted intervals to be created.

      Parameters

      • lo: number
      • hi: number

      Returns s1.Interval

    Other

    hi: number
    lo: number
    • 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.

      Parameters

      Returns boolean

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

      Returns s1.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 number

    • Returns true iff the interval contains p. Assumes p ∈ [-π,π].

      Parameters

      • p: number

      Returns boolean

    • DirectedHausdorffDistance returns the Hausdorff distance to the given interval. For two intervals i and y, this distance is defined by

      h(i, y) = max_{p in i} min_{q in y} d(p, q),

      where d(.,.) is measured along S1.

      Parameters

      Returns number

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

      Parameters

      • margin: number

      Returns s1.Interval

    • Returns true iff the interior of the interval contains p. Assumes p ∈ [-π,π].

      Parameters

      • p: number

      Returns boolean

    • Project returns the closest point in the interval to the given point p. The interval must be non-empty.

      Parameters

      • p: number

      Returns number

    • Compute distance from a to b in [0,2π], in a numerically stable way.

      Parameters

      • a: number
      • b: number

      Returns number