AC-Vector-2.3.1: Efficient geometric vectors and transformations.



This module provides the Range type and several functions for working with ranges.



data Range Source

A Range represents a continuous interval between two Scalar endpoints.




min_point :: !Scalar
max_point :: !Scalar


bound_corners :: Scalar -> Scalar -> RangeSource

Given two Scalars, construct a Range (swapping the endpoints if necessary so that they are in the correct order.

bound_points :: [Scalar] -> RangeSource

Find the bounds of a list of points. (Throws an exception if the list is empty.)

within_bounds :: Scalar -> Range -> BoolSource

Test whether a given Scalar falls within a particular Range.

union :: Range -> Range -> RangeSource

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).

isect :: Range -> Range -> Maybe RangeSource

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.

unions :: [Range] -> RangeSource

Efficiently compute the union of a list of ranges.