ianmackenzie/elm-units-interval/1.1.0

NOTE: the latest version is 3.2.0

Temperature.Interval

This module behaves just like Quantity.Interval, but works on Temperature values.

Represents a finite, closed interval with a minimum and maximum temperature, for example the interval from 20 to 30 degrees Celsius.

Constructors

singleton : Temperature -> Interval

Construct a zero-width interval containing a single temperature.

fromEndpoints : ( Temperature, Temperature ) -> Interval

Construct an interval from its endpoints (the minimum and maximum temperatures of the interval). The two values should be given in order but will be swapped if necessary to ensure a valid interval is returned.

from : Temperature -> Temperature -> Interval

Construct an interval with the two given endpoints (which can be provided in either order).

containingValues : List Temperature -> Maybe Interval

Construct an interval containing all temperatures in the given list. If the list is empty, returns Nothing.

aggregate : List Interval -> Maybe Interval

Construct an interval containing all of the intervals in the given list. If the list is empty, returns Nothing.

Construct an interval containing both of the given intervals.

Attempt to construct an interval containing all the temperatures common to both given intervals. If the intervals do not intersect, returns Nothing. If the two intervals just touch, a singleton interval will be returned.

Properties

endpoints : Interval -> ( Temperature, Temperature )

Get the endpoints of an interval (its minimum and maximum temperatures) as a tuple. The first temperature will always be less than or equal to the second.

minValue : Interval -> Temperature

Get the minimum temperature of an interval.

maxValue : Interval -> Temperature

Get the maximum temperature of an interval.

midpoint : Interval -> Temperature

Get the midpoint of an interval.

width : Interval -> Delta

Get the width of an interval. This will never be negative. Note that this returns a Temperature.Delta, not a Temperature.

Queries

contains : Temperature -> Interval -> Bool

Check if an interval contains a given temperature. The minimum and maximum temperatures of the interval are considered to be contained in the interval.

Check if two intervals touch or overlap (have any temperatures in common). Intervals that just touch each other are considered to intersect.

Check if the second interval is fully contained in the first.

Check if the interval is a singleton (the minimum and maximum temperatures are the same).

Interpolation

interpolate : Interval -> Float -> Temperature

Interpolate between an interval's endpoints; a value of 0.0 corresponds to the minimum temperature of the interval, a value of 0.5 corresponds to its midpoint and a value of 1.0 corresponds to its maximum temperature. Values less than 0.0 or greater than 1.0 can be used to extrapolate.