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.

## Synopsis

- 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.

## Instances

Affine [] # | |

Affine Maybe # | |

Affine Complex # | |

Affine ZipList # | |

Affine Identity # | |

Affine IntMap # | |

Affine Vector # | |

Affine V1 # | |

Affine V2 # | |

Affine V3 # | |

Affine V4 # | |

Affine V0 # | |

Affine Quaternion # | |

Defined in Linear.Affine type Diff Quaternion :: Type -> Type # (.-.) :: Num a => Quaternion a -> Quaternion a -> Diff Quaternion a # (.+^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a # (.-^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a # | |

Affine Plucker # | |

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

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

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

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

Affine ((->) b :: Type -> Type) # | |

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) |

## Instances

Unbox (f a) => Vector Vector (Point f a) # | |

Defined in Linear.Affine basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Point f a) -> m (Vector (Point f a)) # basicUnsafeThaw :: PrimMonad m => Vector (Point f a) -> m (Mutable Vector (PrimState m) (Point f a)) # basicLength :: Vector (Point f a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Point f a) -> Vector (Point f a) # basicUnsafeIndexM :: Monad m => Vector (Point f a) -> Int -> m (Point f a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Point f a) -> Vector (Point f a) -> m () # | |

Unbox (f a) => MVector MVector (Point f a) # | |

Defined in Linear.Affine basicLength :: MVector s (Point f a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Point f a) -> MVector s (Point f a) # basicOverlaps :: MVector s (Point f a) -> MVector s (Point f a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Point f a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (Point f a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> Point f a -> m (MVector (PrimState m) (Point f a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> m (Point f a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> Point f a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (Point f a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (Point f a) -> Point f a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Point f a) -> MVector (PrimState m) (Point f a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Point f a) -> MVector (PrimState m) (Point f a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> m (MVector (PrimState m) (Point f a)) # | |

Monad f => Monad (Point f) # | |

Functor f => Functor (Point f) # | |

Applicative f => Applicative (Point f) # | |

Foldable f => Foldable (Point f) # | |

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

Traversable f => Traversable (Point f) # | |

Distributive f => Distributive (Point f) # | |

Representable f => Representable (Point f) # | |

Eq1 f => Eq1 (Point f) # | |

Ord1 f => Ord1 (Point f) # | |

Defined in Linear.Affine | |

Read1 f => Read1 (Point f) # | |

Defined in Linear.Affine | |

Show1 f => Show1 (Point f) # | |

Serial1 f => Serial1 (Point f) # | |

Defined in Linear.Affine serializeWith :: MonadPut m => (a -> m ()) -> Point f a -> m () # deserializeWith :: MonadGet m => m a -> m (Point f a) # | |

Hashable1 f => Hashable1 (Point f) # | |

Defined in Linear.Affine | |

Apply f => Apply (Point f) # | |

Bind f => Bind (Point f) # | |

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

Defined in Linear.Affine | |

Metric f => Metric (Point f) # | |

Finite f => Finite (Point f) # | |

R1 f => R1 (Point f) # | |

Defined in Linear.Affine | |

R2 f => R2 (Point f) # | |

R3 f => R3 (Point f) # | |

R4 f => R4 (Point f) # | |

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

Generic1 (Point f :: Type -> Type) # | |

Eq (f a) => Eq (Point f a) # | |

Fractional (f a) => Fractional (Point f a) # | |

(Typeable f, Typeable a, Data (f a)) => Data (Point f a) # | |

Defined in Linear.Affine gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Point f a -> c (Point f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Point f a) # toConstr :: Point f a -> Constr # dataTypeOf :: Point f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Point f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Point f a)) # gmapT :: (forall b. Data b => b -> b) -> Point f a -> Point f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Point f a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Point f a -> r # gmapQ :: (forall d. Data d => d -> u) -> Point f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Point f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Point f a -> m (Point f a) # | |

Num (f a) => Num (Point f a) # | |

Ord (f a) => Ord (Point f a) # | |

Defined in Linear.Affine | |

Read (f a) => Read (Point f a) # | |

Show (f a) => Show (Point f a) # | |

Ix (f a) => Ix (Point f a) # | |

Defined in Linear.Affine range :: (Point f a, Point f a) -> [Point f a] # index :: (Point f a, Point f a) -> Point f a -> Int # unsafeIndex :: (Point f a, Point f a) -> Point f a -> Int inRange :: (Point f a, Point f a) -> Point f a -> Bool # rangeSize :: (Point f a, Point f a) -> Int # unsafeRangeSize :: (Point f a, Point f a) -> Int | |

Generic (Point f a) # | |

Storable (f a) => Storable (Point f a) # | |

Defined in Linear.Affine | |

Binary (f a) => Binary (Point f a) # | |

Serial (f a) => Serial (Point f a) # | |

Defined in Linear.Affine | |

Serialize (f a) => Serialize (Point f a) # | |

NFData (f a) => NFData (Point f a) # | |

Defined in Linear.Affine | |

Hashable (f a) => Hashable (Point f a) # | |

Defined in Linear.Affine | |

Unbox (f a) => Unbox (Point f a) # | |

Defined in Linear.Affine | |

Ixed (f a) => Ixed (Point f a) # | |

Defined in Linear.Affine | |

Wrapped (Point f a) # | |

Epsilon (f a) => Epsilon (Point f a) # | |

Defined in Linear.Affine | |

t ~ Point g b => Rewrapped (Point f a) t # | |

Defined in Linear.Affine | |

Traversable f => Each (Point f a) (Point f b) a b # | |

newtype MVector s (Point f a) # | |

Defined in Linear.Affine | |

type Rep (Point f) # | |

Defined in Linear.Affine | |

type Size (Point f) # | |

Defined in Linear.Affine | |

type Diff (Point f) # | |

Defined in Linear.Affine | |

type Rep1 (Point f :: Type -> Type) # | |

type Rep (Point f a) # | |

Defined in Linear.Affine | |

newtype Vector (Point f a) # | |

Defined in Linear.Affine | |

type Index (Point f a) # | |

Defined in Linear.Affine | |

type IxValue (Point f a) # | |

Defined in Linear.Affine | |

type Unwrapped (Point f a) # | |

Defined in Linear.Affine |