License | BSD-style (see the file LICENSE) |
---|---|
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell98 |
Linear.Affine
Description
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 Source #
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@
Methods
(.-.) :: Num a => p a -> p a -> Diff p a infixl 6 Source #
Get the difference between two points as a vector offset.
(.+^) :: Num a => p a -> Diff p a -> p a infixl 6 Source #
Add a vector offset to a point.
(.-^) :: Num a => p a -> Diff p a -> p a infixl 6 Source #
Subtract a vector offset from a point.
Instances
Affine [] Source # | |
Affine Maybe Source # | |
Affine Identity Source # | |
Defined in Linear.Affine | |
Affine Complex Source # | |
Affine ZipList Source # | |
Affine Vector Source # | |
Affine IntMap Source # | |
Affine V1 Source # | |
Affine V2 Source # | |
Affine V3 Source # | |
Affine V4 Source # | |
Affine V0 Source # | |
Affine Quaternion Source # | |
Defined in Linear.Affine Associated Types type Diff Quaternion :: Type -> Type Source # Methods (.-.) :: Num a => Quaternion a -> Quaternion a -> Diff Quaternion a Source # (.+^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a Source # (.-^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a Source # | |
Affine Plucker Source # | |
(Eq k, Hashable k) => Affine (HashMap k) Source # | |
Defined in Linear.Affine | |
Ord k => Affine (Map k) Source # | |
Additive f => Affine (Point f) Source # | |
Defined in Linear.Affine | |
Dim n => Affine (V n) Source # | |
Affine ((->) b :: Type -> Type) Source # | |
qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a Source #
Compute the quadrance of the difference (the square of the distance)
distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a Source #
Distance between two points in an affine space
A handy wrapper to help distinguish points from vectors at the type level
Constructors
P (f a) |
Instances
Unbox (f a) => Vector Vector (Point f a) Source # | |
Defined in Linear.Affine Methods basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Point f a) -> m (Vector (Point f a)) Source # basicUnsafeThaw :: PrimMonad m => Vector (Point f a) -> m (Mutable Vector (PrimState m) (Point f a)) Source # basicLength :: Vector (Point f a) -> Int Source # basicUnsafeSlice :: Int -> Int -> Vector (Point f a) -> Vector (Point f a) Source # basicUnsafeIndexM :: Monad m => Vector (Point f a) -> Int -> m (Point f a) Source # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Point f a) -> Vector (Point f a) -> m () Source # elemseq :: Vector (Point f a) -> Point f a -> b -> b Source # | |
Unbox (f a) => MVector MVector (Point f a) Source # | |
Defined in Linear.Affine Methods basicLength :: MVector s (Point f a) -> Int Source # basicUnsafeSlice :: Int -> Int -> MVector s (Point f a) -> MVector s (Point f a) Source # basicOverlaps :: MVector s (Point f a) -> MVector s (Point f a) -> Bool Source # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Point f a)) Source # basicInitialize :: PrimMonad m => MVector (PrimState m) (Point f a) -> m () Source # basicUnsafeReplicate :: PrimMonad m => Int -> Point f a -> m (MVector (PrimState m) (Point f a)) Source # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> m (Point f a) Source # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> Point f a -> m () Source # basicClear :: PrimMonad m => MVector (PrimState m) (Point f a) -> m () Source # basicSet :: PrimMonad m => MVector (PrimState m) (Point f a) -> Point f a -> m () Source # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Point f a) -> MVector (PrimState m) (Point f a) -> m () Source # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Point f a) -> MVector (PrimState m) (Point f a) -> m () Source # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Point f a) -> Int -> m (MVector (PrimState m) (Point f a)) Source # | |
Monad f => Monad (Point f) Source # | |
Functor f => Functor (Point f) Source # | |
Applicative f => Applicative (Point f) Source # | |
Foldable f => Foldable (Point f) Source # | |
Defined in Linear.Affine Methods fold :: Monoid m => Point f m -> m foldMap :: Monoid m => (a -> m) -> Point f a -> 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) Source # | |
Distributive f => Distributive (Point f) Source # | |
Defined in Linear.Affine | |
Representable f => Representable (Point f) Source # | |
Show1 f => Show1 (Point f) Source # | |
Defined in Linear.Affine Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Point f a -> ShowS liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Point f a] -> ShowS | |
Read1 f => Read1 (Point f) Source # | |
Defined in Linear.Affine Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Point f a) liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Point f a] liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Point f a) liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Point f a] | |
Ord1 f => Ord1 (Point f) Source # | |
Defined in Linear.Affine Methods liftCompare :: (a -> b -> Ordering) -> Point f a -> Point f b -> Ordering | |
Eq1 f => Eq1 (Point f) Source # | |
Defined in Linear.Affine | |
Serial1 f => Serial1 (Point f) Source # | |
Defined in Linear.Affine Methods serializeWith :: MonadPut m => (a -> m ()) -> Point f a -> m () Source # deserializeWith :: MonadGet m => m a -> m (Point f a) Source # | |
Hashable1 f => Hashable1 (Point f) Source # | |
Defined in Linear.Affine Methods liftHashWithSalt :: (Int -> a -> Int) -> Int -> Point f a -> Int Source # | |
Apply f => Apply (Point f) Source # | |
Bind f => Bind (Point f) Source # | |
Additive f => Additive (Point f) Source # | |
Defined in Linear.Affine Methods zero :: Num a => Point f a Source # (^+^) :: Num a => Point f a -> Point f a -> Point f a Source # (^-^) :: Num a => Point f a -> Point f a -> Point f a Source # lerp :: Num a => a -> Point f a -> Point f a -> Point f a Source # liftU2 :: (a -> a -> a) -> Point f a -> Point f a -> Point f a Source # liftI2 :: (a -> b -> c) -> Point f a -> Point f b -> Point f c Source # | |
Metric f => Metric (Point f) Source # | |
Finite f => Finite (Point f) Source # | |
R1 f => R1 (Point f) Source # | |
R2 f => R2 (Point f) Source # | |
R3 f => R3 (Point f) Source # | |
R4 f => R4 (Point f) Source # | |
Additive f => Affine (Point f) Source # | |
Defined in Linear.Affine | |
Generic1 (Point f :: Type -> Type) Source # | |
Eq (f a) => Eq (Point f a) Source # | |
Fractional (f a) => Fractional (Point f a) Source # | |
Defined in Linear.Affine | |
(Typeable f, Typeable a, Data (f a)) => Data (Point f a) Source # | |
Defined in Linear.Affine Methods 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 :: forall r r'. (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) Source # | |
Ord (f a) => Ord (Point f a) Source # | |
Defined in Linear.Affine | |
Read (f a) => Read (Point f a) Source # | |
Defined in Linear.Affine | |
Show (f a) => Show (Point f a) Source # | |
Ix (f a) => Ix (Point f a) Source # | |
Defined in Linear.Affine Methods 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) Source # | |
Storable (f a) => Storable (Point f a) Source # | |
Defined in Linear.Affine Methods peekElemOff :: Ptr (Point f a) -> Int -> IO (Point f a) pokeElemOff :: Ptr (Point f a) -> Int -> Point f a -> IO () peekByteOff :: Ptr b -> Int -> IO (Point f a) pokeByteOff :: Ptr b -> Int -> Point f a -> IO () | |
Serial (f a) => Serial (Point f a) Source # | |
Serialize (f a) => Serialize (Point f a) Source # | |
Hashable (f a) => Hashable (Point f a) Source # | |
Defined in Linear.Affine | |
Unbox (f a) => Unbox (Point f a) Source # | |
Defined in Linear.Affine | |
Ixed (f a) => Ixed (Point f a) Source # | |
Defined in Linear.Affine | |
Wrapped (Point f a) Source # | |
Binary (f a) => Binary (Point f a) Source # | |
NFData (f a) => NFData (Point f a) Source # | |
Defined in Linear.Affine | |
Epsilon (f a) => Epsilon (Point f a) Source # | |
Defined in Linear.Affine | |
t ~ Point g b => Rewrapped (Point f a) t Source # | |
Defined in Linear.Affine | |
Traversable f => Each (Point f a) (Point f b) a b Source # | |
newtype MVector s (Point f a) Source # | |
Defined in Linear.Affine | |
type Rep (Point f) Source # | |
Defined in Linear.Affine | |
type Size (Point f) Source # | |
Defined in Linear.Affine | |
type Diff (Point f) Source # | |
Defined in Linear.Affine | |
type Rep1 (Point f :: Type -> Type) Source # | |
Defined in Linear.Affine type Rep1 (Point f :: Type -> Type) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.20.9-DOReBBPX45Z7wmILVkBViE" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f))) | |
type Rep (Point f a) Source # | |
Defined in Linear.Affine type Rep (Point f a) = D1 ('MetaData "Point" "Linear.Affine" "linear-1.20.9-DOReBBPX45Z7wmILVkBViE" 'True) (C1 ('MetaCons "P" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)))) | |
newtype Vector (Point f a) Source # | |
Defined in Linear.Affine | |
type Index (Point f a) Source # | |
Defined in Linear.Affine | |
type IxValue (Point f a) Source # | |
Defined in Linear.Affine | |
type Unwrapped (Point f a) Source # | |
Defined in Linear.Affine |