Portability | ghc |
---|---|

Stability | unstable |

Maintainer | Andy Gill <andygill@ku.edu> |

This module contains some general utilties.

- innerSteps :: Int -> [R]
- outerSteps :: Int -> [R]
- fracPart :: R -> R
- fromPolar :: (R, Radian) -> Point
- toPolar :: Point -> (R, Radian)
- angleOfLine :: (Point, Point) -> Radian
- interpBool :: Bool -> UI
- sampleUI :: UI -> Bool
- withMask :: a -> Bool -> Maybe a
- withDefault :: a -> Maybe a -> a
- choose :: a -> a -> Bool -> a
- insideRegion :: (Point, Point) -> Point -> Bool
- insideCircle :: Point -> R -> Point -> Bool
- distance :: Point -> Point -> R
- intervalOnLine :: (Point, Point) -> Point -> R
- circleOfDots :: Int -> [Point]

# Utilties for `R`

.

innerSteps :: Int -> [R]Source

innerSteps takes n even steps from 0 .. 1, by not actually touching 0 or 1. The first and last step are 1/2 the size of the others, so that repeated innerSteps can be tiled neatly.

outerSteps :: Int -> [R]Source

outerSteps takes n even steps from 0 .. 1, starting with 0, and ending with 1, returning n+1 elements.

angleOfLine :: (Point, Point) -> RadianSource

# Pointwise operators.

interpBool :: Bool -> UISource

Covert a Bool (mask point) into a unit interval.

withDefault :: a -> Maybe a -> aSource

With a default if you do not have a Just.

# Point Utilties.

insideCircle :: Point -> R -> Point -> BoolSource

is a `Point`

inside a circle, where the first two arguments are the center of the circle,
and the radius.

distance :: Point -> Point -> RSource

What is the `distance`

between two points in R2?
This is optimised for the normal form `distance p1 p2 <= v`

, which avoids using `sqrt`

.

intervalOnLine :: (Point, Point) -> Point -> RSource

`intervalOnLine`

find the place on a line (between 0 and 1) that is closest to the given point.

circleOfDots :: Int -> [Point]Source

circleOfDots generates a set of points between (-1..1,-1..1), inside a circle.