{- |
This module provides the 'Range' type and several functions for working with ranges.
-}moduleData.BoundingBox.RangewhereimportData.Vector.Class{- |
A 'Range' represents a continuous interval between two 'Scalar' endpoints.
-}dataRange=Range{min_point,max_point::{-# UNPACK #-}!Scalar}deriving(Eq,Show)-- | Given two 'Scalar's, construct a 'Range' (swapping the endpoints if necessary so that they are in the correct order.bound_corners::Scalar->Scalar->Rangebound_cornersxaxb=Range(minxaxb)(maxxaxb)-- | Find the bounds of a list of points. (Throws an exception if the list is empty.)bound_points::[Scalar]->Rangebound_pointsxs=Range(minimumxs)(maximumxs)-- | Test whether a given 'Scalar' falls within a particular 'Range'.within_bounds::Scalar->Range->Boolwithin_boundsx(Rangex0x1)=x0<=x&&x<=x1-- | Take the union of two ranges. The resulting 'Range' contains all points that the original ranges contained, plus any points between them (if the original ranges don't overlap).union::Range->Range->Rangeunion(Rangex00x01)(Rangex10x11)=Range(minx00x01)(maxx01x11)-- | Take the intersection of two ranges. If the ranges do not overlap, the intersection is empty, and 'Nothing' is returned. (This is a good way to check whether two ranges overlap or not.) Otherwise a new 'Range' is returned that contains only the points common to both ranges.isect::Range->Range->MaybeRangeisect(Rangex00x01)(Rangex10x11)=ifx00<x10thenifx10<x01thenJust(Rangex10(minx01x11))elseNothingelseifx00<x11thenJust(Rangex00(minx01x11))elseNothing