Struct s2::s1::interval::Interval

source ·
pub struct Interval {
    pub lo: f64,
    pub hi: f64,
}
Expand description

Interval represents a closed interval on a unit circle. Zero-length intervals (where Lo == Hi) represent single points. If Lo > Hi then the interval is “inverted”. The point at (-1, 0) on the unit circle has two valid representations, [π,π] and [-π,-π]. We normalize the latter to the former in Interval::new. There are two special intervals that take advantage of that:

  • the full interval, [-π,π], and
  • the empty interval, [π,-π]. Treat the exported fields as read-only.

Fields§

§lo: f64§hi: f64

Implementations§

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

from_point_pair returns the minimal interval containing the two given points. Both arguments must be in [-π,π].

is_valid reports whether the interval is valid.

is_full reports whether the interval is full.

is_empty reports whether the interval is empty.

is_inverted reports whether the interval is inverted; that is, whether Lo > Hi.

invert returns the interval with endpoints swapped.

center returns the midpoint of the interval. It is undefined for full and empty intervals.

len returns the length of the interval. The length of an empty interval is negative.

fast_contains returns true iff the interval contains p. Assumes p ∈ (-π,π].

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

contains_interval returns true iff the interval contains oi.

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

interior_contains_interval returns true iff the interior of the interval contains oi.

intersects returns true iff the interval contains any points in common with oi.

interior_intersects returns true iff the interior of the interval contains any points in common with other, including the latter’s boundary.

union returns the smallest interval that contains both the interval and oi.

intersection returns the smallest interval that contains the intersection of the interval and oi.

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.

Trait Implementations§

add returns the interval expanded by the minimum amount necessary such that it contains the given point “p” (an angle in the range [-Pi, Pi]).

The resulting type after applying the + operator.
The resulting type after applying the + operator.
Performs the + operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.