| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Direction.Cardinal
Description
Cardinal and Intercardinal directions.
Synopsis
- data CardinalDirection
- oppositeDirection :: CardinalDirection -> CardinalDirection
- data InterCardinalDirection
- interCardinalsOf :: CardinalDirection -> Vector 2 InterCardinalDirection
- classifyDirection :: (Ord r, Num r) => Vector 2 r -> Either CardinalDirection InterCardinalDirection
- classifyDirection' :: (Ord r, Num r) => Vector 2 r -> Maybe (Either CardinalDirection InterCardinalDirection)
Documentation
data CardinalDirection Source #
The four cardinal directions.
Instances
oppositeDirection :: CardinalDirection -> CardinalDirection Source #
Computes the direction opposite to the given one.
data InterCardinalDirection Source #
Intercardinal directions
Instances
interCardinalsOf :: CardinalDirection -> Vector 2 InterCardinalDirection Source #
Get the two intercardinal directions, in increasing order, corresponding to the cardinal direction.
classifyDirection :: (Ord r, Num r) => Vector 2 r -> Either CardinalDirection InterCardinalDirection Source #
Classfiy the direction of the given vector
pre: the vector is non-zero
classifyDirection' :: (Ord r, Num r) => Vector 2 r -> Maybe (Either CardinalDirection InterCardinalDirection) Source #
Classfiy the direction of the given vector. Returns nothing if the vector is zero