Safe Haskell | None |
---|---|

Language | Haskell2010 |

A 2-dimensional point.

## Synopsis

- data Point a = Point {}
- rotateP :: TrigField a => a -> Point a -> Point a
- gridP :: FieldSpace (Range a) => (a -> a) -> Range a -> Grid (Range a) -> [Point a]
- dotP :: (Multiplicative a, Additive a) => Point a -> Point a -> a
- (<.>) :: (Multiplicative a, Additive a) => Point a -> Point a -> a
- crossP :: (Multiplicative a, Subtractive a) => Point a -> Point a -> a
- flipY :: Subtractive a => Point a -> Point a
- data Line a = Line {}
- lineSolve :: ExpField a => Line a -> (a, a, a)
- lineDistance :: ExpField a => Line a -> Point a -> a
- closestPoint :: Field a => Line a -> Point a -> Point a
- lineIntersect :: (Ord a, Epsilon a, Signed a, Field a) => Line a -> Line a -> Maybe (Point a)
- translate :: TrigField a => Point a -> Transform a
- scaleT :: TrigField a => Point a -> Transform a
- skew :: TrigField a => Point a -> Transform a

# Documentation

A 2-dimensional Point of a's

In contrast with a tuple, a Point is functorial over both arguments.

`>>>`

`let p = Point 1 1`

`>>>`

Point 2 2`p + p`

`>>>`

Point 2 2`(2*) <$> p`

A major reason for this bespoke treatment (compared to just using linear, say) is that Points do not have maximums and minimums but they do form a lattice, and this is useful for folding sets of points to find out the (rectangular) Space they occupy.

`>>>`

Point 0 0`Point 0 1 /\ Point 1 0`

`>>>`

Point 1 1`Point 0 1 \/ Point 1 0`

This is used extensively in chart-svg to ergonomically obtain chart areas.

space1 [Point 1 0, Point 0 1] :: Rect Double

Rect 0.0 1.0 0.0 1.0

#### Instances

rotateP :: TrigField a => a -> Point a -> Point a Source #

rotate a point by x relative to the origin

`>>>`

Point 6.123233995736766e-17 1.0`rotateP (pi/2) (Point 1 0)`

gridP :: FieldSpace (Range a) => (a -> a) -> Range a -> Grid (Range a) -> [Point a] Source #

Create Points for a formulae y = f(x) across an x range

`>>>`

[Point 0.0 0.0,Point 1.0 1.0,Point 2.0 4.0,Point 3.0 9.0,Point 4.0 16.0]`gridP (^2) (Range 0 4) 4`

(<.>) :: (Multiplicative a, Additive a) => Point a -> Point a -> a infix 4 Source #

dot product operator

crossP :: (Multiplicative a, Subtractive a) => Point a -> Point a -> a Source #

cross product

A line is a composed of 2 `Point`

s

#### Instances

Functor Line Source # | |

Foldable Line Source # | |

Defined in NumHask.Space.Point fold :: Monoid m => Line m -> m # foldMap :: Monoid m => (a -> m) -> Line a -> m # foldMap' :: Monoid m => (a -> m) -> Line a -> m # foldr :: (a -> b -> b) -> b -> Line a -> b # foldr' :: (a -> b -> b) -> b -> Line a -> b # foldl :: (b -> a -> b) -> b -> Line a -> b # foldl' :: (b -> a -> b) -> b -> Line a -> b # foldr1 :: (a -> a -> a) -> Line a -> a # foldl1 :: (a -> a -> a) -> Line a -> a # elem :: Eq a => a -> Line a -> Bool # maximum :: Ord a => Line a -> a # | |

Traversable Line Source # | |

Eq a => Eq (Line a) Source # | |

Show a => Show (Line a) Source # | |

(Multiplicative a, Additive a) => Affinity (Line a) a Source # | |

lineSolve :: ExpField a => Line a -> (a, a, a) Source #

Return the parameters (a, b, c) for the line equation `a*x + b*y + c = 0`

.

lineDistance :: ExpField a => Line a -> Point a -> a Source #

Return the signed distance from a point to the line. If the distance is negative, the point lies to the right of the line

closestPoint :: Field a => Line a -> Point a -> Point a Source #

Return the point on the line closest to the given point.