License | BSD-style (see the file LICENSE) |
---|---|

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | provisional |

Portability | portable |

Safe Haskell | Trustworthy |

Language | Haskell98 |

Operations on affine spaces.

- class Additive (Diff p) => Affine p where
- qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a
- distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a
- newtype Point f a = P (f a)
- lensP :: Lens' (Point g a) (g a)
- _Point :: Iso' (Point f a) (f a)
- (.#) :: Coercible b a => (b -> c) -> (a -> b) -> a -> c
- (#.) :: Coercible c b => (b -> c) -> (a -> b) -> a -> c
- unP :: Point f a -> f a
- origin :: (Additive f, Num a) => Point f a
- relative :: (Additive f, Num a) => Point f a -> Iso' (Point f a) (f a)

# Documentation

class Additive (Diff p) => Affine p where #

An affine space is roughly a vector space in which we have forgotten or at least pretend to have forgotten the origin.

a .+^ (b .-. a) = b@ (a .+^ u) .+^ v = a .+^ (u ^+^ v)@ (a .-. b) ^+^ v = (a .+^ v) .-. q@

(.-.) :: Num a => p a -> p a -> Diff p a infixl 6 #

Get the difference between two points as a vector offset.

(.+^) :: Num a => p a -> Diff p a -> p a infixl 6 #

Add a vector offset to a point.

(.-^) :: Num a => p a -> Diff p a -> p a infixl 6 #

Subtract a vector offset from a point.

Affine [] # | |

Affine Maybe # | |

Affine Identity # | |

Affine Complex # | |

Affine ZipList # | |

Affine IntMap # | |

Affine Vector # | |

Affine V0 # | |

Affine V1 # | |

Affine V2 # | |

Affine V3 # | |

Affine V4 # | |

Affine Plucker # | |

Affine Quaternion # | |

Affine ((->) b) # | |

Ord k => Affine (Map k) # | |

(Eq k, Hashable k) => Affine (HashMap k) # | |

Additive f => Affine (Point f) # | |

Dim * n => Affine (V * n) # | |

qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a #

Compute the quadrance of the difference (the square of the distance)

distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a #

Distance between two points in an affine space

A handy wrapper to help distinguish points from vectors at the type level

P (f a) |