Interval represents a closed interval on ℝ. Zero-length intervals (where Lo == Hi) represent single points. If Lo > Hi then the interval is empty.
type Interval struct { Lo, Hi float64 }
func EmptyInterval() Interval
EmptyInterval returns an empty interval.
func IntervalFromPoint(p float64) Interval
IntervalFromPoint returns an interval representing a single point.
func (i Interval) AddPoint(p float64) Interval
AddPoint returns the interval expanded so that it contains the given point.
func (i Interval) ApproxEqual(other Interval) bool
ApproxEqual reports whether the interval can be transformed into the given 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.
func (i Interval) Center() float64
Center returns the midpoint of the interval. It is undefined for empty intervals.
func (i Interval) ClampPoint(p float64) float64
ClampPoint returns the closest point in the interval to the given point "p". The interval must be non-empty.
func (i Interval) Contains(p float64) bool
Contains returns true iff the interval contains p.
func (i Interval) ContainsInterval(oi Interval) bool
ContainsInterval returns true iff the interval contains oi.
func (i Interval) DirectedHausdorffDistance(other Interval) float64
DirectedHausdorffDistance returns the Hausdorff distance to the given interval. For two intervals x and y, this distance is defined as
h(x, y) = max_{p in x} min_{q in y} d(p, q).
func (i Interval) Equal(oi Interval) bool
Equal returns true iff the interval contains the same points as oi.
func (i Interval) Expanded(margin float64) Interval
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. Any expansion of an empty interval remains empty.
func (i Interval) InteriorContains(p float64) bool
InteriorContains returns true iff the interval strictly contains p.
func (i Interval) InteriorContainsInterval(oi Interval) bool
InteriorContainsInterval returns true iff the interval strictly contains oi.
func (i Interval) InteriorIntersects(oi Interval) bool
InteriorIntersects returns true iff the interior of the interval contains any points in common with oi, including the latter's boundary.
func (i Interval) Intersection(j Interval) Interval
Intersection returns the interval containing all points common to i and j.
func (i Interval) Intersects(oi Interval) bool
Intersects returns true iff the interval contains any points in common with oi.
func (i Interval) IsEmpty() bool
IsEmpty reports whether the interval is empty.
func (i Interval) Length() float64
Length returns the length of the interval. The length of an empty interval is negative.
func (i Interval) String() string
func (i Interval) Union(other Interval) Interval
Union returns the smallest interval that contains this interval and the given interval.