vector-space-points 0.1.2.1 → 0.1.3
raw patch · 2 files changed
+35/−14 lines, 2 files
Files
- src/Data/AffineSpace/Point.hs +34/−13
- vector-space-points.cabal +1/−1
src/Data/AffineSpace/Point.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE TypeFamilies- , MultiParamTypeClasses- , FlexibleInstances- , DeriveFunctor- , DeriveDataTypeable- #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-} ----------------------------------------------------------------------------- -- | -- Module : Data.AffineSpace.Point@@ -18,17 +17,19 @@ module Data.AffineSpace.Point ( -- * Points-- Point(..), unPoint, origin, (*.)+ Point(..), unPoint, origin, (*.), mirror, + -- * Reflection through a point+ relative, relative2, relative3,+ reflectThrough, ) where -import Data.VectorSpace-import Data.AffineSpace+import Data.AffineSpace+import Data.VectorSpace -import Control.Newtype-import Data.Data (Data)-import Data.Typeable (Typeable)+import Control.Newtype+import Data.Data (Data)+import Data.Typeable (Typeable) ------------------------------------------------------------ -- Points ------------------------------------------------@@ -66,3 +67,23 @@ -- | Scale a point by a scalar. (*.) :: VectorSpace v => Scalar v -> Point v -> Point v s *. P v = P (s *^ v)++-- | Reflect a point through the 'origin'.+mirror :: AdditiveGroup v => Point v -> Point v+mirror = reflectThrough origin++-- | Apply a transformation relative to the given point.+relative :: AffineSpace p => p -> (Diff p -> Diff p) -> p -> p+relative p f = (p .+^) . f . (.-. p)++-- | Apply a transformation relative to the given point.+relative2 :: AffineSpace p => p -> (Diff p -> Diff p -> Diff p) -> p -> p -> p+relative2 p f x y = (p .+^) $ f (inj x) (inj y) where inj = (.-. p)++-- | Apply a transformation relative to the given point.+relative3 :: AffineSpace p => p -> (Diff p -> Diff p -> Diff p -> Diff p) -> p -> p -> p -> p+relative3 p f x y z = (p .+^) $ f (inj x) (inj y) (inj z) where inj = (.-. p)++-- | Mirror a point through a given point.+reflectThrough :: AffineSpace p => p -> p -> p+reflectThrough o = relative o negateV
vector-space-points.cabal view
@@ -1,5 +1,5 @@ name: vector-space-points-version: 0.1.2.1+version: 0.1.3 synopsis: A type for points, as distinct from vectors. description: A type for points, as distinct from vectors, built on top of Data.AffineSpace.