Copyright | (c) Jonatan H Sundqvist 2016 |
---|---|

License | MIT |

Maintainer | Jonatan H Sundqvist |

Stability | experimental|stable |

Portability | POSIX (not sure) |

Safe Haskell | None |

Language | Haskell2010 |

- module Cartesian.Types
- module Cartesian.Lenses
- overlap :: Ord n => (n, n) -> (n, n) -> Maybe (n, n)
- fromCorners :: (Applicative v, Num n, Ord n) => v n -> v n -> BoundingBox (v n)
- fromAxes :: Applicative v => Axes v n -> BoundingBox (v n)
- fromExtents :: (Applicative v, Num n) => Axes v n -> BoundingBox (v n)
- intersect :: (Applicative v, Traversable v, Ord n, Num n) => BoundingBox (v n) -> BoundingBox (v n) -> Maybe (BoundingBox (v n))

# Documentation

Types

module Cartesian.Types

Lenses

module Cartesian.Lenses

Functions

overlap :: Ord n => (n, n) -> (n, n) -> Maybe (n, n) Source #

Finds the overlap between two ranges (lower bound, upper bound).
| Yields the overlap of two closed intervals (n ∈ R)
TODO: Normalise intervals (eg. (12, 5) -> (5, 12))
TODO: Type for intervals (which would also encode the `openness`

of the lower and upper limits)

fromCorners :: (Applicative v, Num n, Ord n) => v n -> v n -> BoundingBox (v n) Source #

Cross product cross :: (Vector v, Num f) => v f -> v f -> v f cross a b = _

Euclidean distance between two points euclidean :: (Vector v, Floating f) => v f -> v f -> f euclidean a b = sqrt $ dot a b

Vector -> (magnitude, argument) polar :: (Floating a, Eq a) => Vector a -> (a, a) polar v@(Vector x y) = (magnitude v, argument v)

Creates a bounding box from two opposite corners
TODO: Better name (?)
TODO: Don't make assumptions about WHICH corners they are (✓)
TODO: Should we care about degenerate cases (such as `a`

and `b`

being identical)

fromAxes :: Applicative v => Axes v n -> BoundingBox (v n) Source #

fromExtents :: (Applicative v, Num n) => Axes v n -> BoundingBox (v n) Source #

Top Left Bottom Right

intersect :: (Applicative v, Traversable v, Ord n, Num n) => BoundingBox (v n) -> BoundingBox (v n) -> Maybe (BoundingBox (v n)) Source #

Finds the intersection (boolean AND) of two bounding boxes