Spherical.R1.Interval

Represents a closed interval on ℝ¹.

Source

Summary

add_point(interval, point)

Returns a copy of interval containing the given point

approx_equal(first, second)

Reports whether the first interval can be transformed into the second interval by moving each endpoint a small distance

center(interval)

Returns the midpoint of the interval

clamp_point(interval, point)

Returns the closest point in the interval to the given point

contains?(first, second)

Checks if the interval contains point

expanded(interval, margin)

Returns an interval that has been expanded on each side by margin

interior_contains?(interval, point)

Checks if the interval strictly contains point

interior_intersects?(first, second)

Check if the interior of the first contains any points in common with second, including the latter’s boundary

intersection(first, second)

Returns the interval containing all points common to first and second

intersects?(first, second)

Check if first contains any points in common with second

is_empty?(interval)

Checks whether the interval is empty

is_equal?(interval, interval)

Checks if the intervals contains the same points

length(interval)

Returns the length of the interval

new()

Returns an empty interval

new(point)

Returns an interval representing a single point

new(a, b)

Returns an interval between a and b

union(first, second)

Returns the smallest interval that contains the first and second intervals

Types

t :: %Spherical.R1.Interval{lo: number, hi: number}

Functions

add_point(interval, point)

Returns a copy of interval containing the given point.

Source
approx_equal(first, second)

Reports whether the first interval can be transformed into the second interval by moving each endpoint a small distance.

The empty interval is considered to be positioned arbitrarily on the real line, so any interval with a small enough length will match the empty interval.

Source
center(interval)

Returns the midpoint of the interval.

Source
clamp_point(interval, point)

Returns the closest point in the interval to the given point.

The interval must be non-empty.

Source
contains?(first, second)

Checks if the interval contains point.

Source
expanded(interval, margin)

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.

Any expansion of an empty interval remains empty.

Source
interior_contains?(interval, point)

Checks if the interval strictly contains point.

Source
interior_intersects?(first, second)

Check if the interior of the first contains any points in common with second, including the latter’s boundary.

Source
intersection(first, second)

Returns the interval containing all points common to first and second.

Source
intersects?(first, second)

Check if first contains any points in common with second.

Source
is_empty?(interval)

Checks whether the interval is empty.

Source
is_equal?(interval, interval)

Checks if the intervals contains the same points.

Source
length(interval)

Returns the length of the interval.

The length of an empty interval is negative.

Source
new()

Returns an empty interval.

Source
new(point)

Returns an interval representing a single point.

Source
new(a, b)

Returns an interval between a and b.

Source
union(first, second)

Returns the smallest interval that contains the first and second intervals.

Source