{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveLift #-}
#ifndef MIN_VERSION_vector
#define MIN_VERSION_vector(x,y,z) 1
#endif
#ifndef MIN_VERSION_transformers
#define MIN_VERSION_transformers(x,y,z) 1
#endif
module Linear.Plucker
( Plucker(..)
, squaredError
, isotropic
, (><)
, plucker
, plucker3D
, parallel
, intersects
, LinePass(..)
, passes
, quadranceToOrigin
, closestToOrigin
, isLine
, coincides
, coincides'
, p01, p02, p03
, p10, p12, p13
, p20, p21, p23
, p30, p31, p32
, e01, e02, e03, e12, e31, e23
) where
import Control.Applicative
import Control.DeepSeq (NFData(rnf))
import Control.Monad (liftM)
import Control.Monad.Fix
import Control.Monad.Zip
import Control.Lens as Lens hiding (index, (<.>))
import Data.Binary as Binary
import Data.Bytes.Serial
import Data.Distributive
import Data.Foldable as Foldable
import qualified Data.Foldable.WithIndex as WithIndex
import Data.Functor.Bind
import Data.Functor.Classes
import Data.Functor.Rep
import qualified Data.Functor.WithIndex as WithIndex
import Data.Hashable
import Data.Semigroup
import Data.Semigroup.Foldable
import Data.Serialize as Cereal
import qualified Data.Traversable.WithIndex as WithIndex
import qualified Data.Vector as V
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Unboxed.Base as U
import Foreign.Ptr (castPtr)
import Foreign.Storable (Storable(..))
import GHC.Arr (Ix(..))
import GHC.Generics (Generic, Generic1)
#if defined(MIN_VERSION_template_haskell)
import Language.Haskell.TH.Syntax (Lift)
#endif
import Linear.Epsilon
import Linear.Metric
import Linear.V
import Linear.V2
import Linear.V3
import Linear.V4
import Linear.Vector
import System.Random (Random(..))
data Plucker a = Plucker !a !a !a !a !a !a deriving (Plucker a -> Plucker a -> Bool
(Plucker a -> Plucker a -> Bool)
-> (Plucker a -> Plucker a -> Bool) -> Eq (Plucker a)
forall a. Eq a => Plucker a -> Plucker a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Plucker a -> Plucker a -> Bool
$c/= :: forall a. Eq a => Plucker a -> Plucker a -> Bool
== :: Plucker a -> Plucker a -> Bool
$c== :: forall a. Eq a => Plucker a -> Plucker a -> Bool
Eq,Eq (Plucker a)
Eq (Plucker a)
-> (Plucker a -> Plucker a -> Ordering)
-> (Plucker a -> Plucker a -> Bool)
-> (Plucker a -> Plucker a -> Bool)
-> (Plucker a -> Plucker a -> Bool)
-> (Plucker a -> Plucker a -> Bool)
-> (Plucker a -> Plucker a -> Plucker a)
-> (Plucker a -> Plucker a -> Plucker a)
-> Ord (Plucker a)
Plucker a -> Plucker a -> Bool
Plucker a -> Plucker a -> Ordering
Plucker a -> Plucker a -> Plucker a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Plucker a)
forall a. Ord a => Plucker a -> Plucker a -> Bool
forall a. Ord a => Plucker a -> Plucker a -> Ordering
forall a. Ord a => Plucker a -> Plucker a -> Plucker a
min :: Plucker a -> Plucker a -> Plucker a
$cmin :: forall a. Ord a => Plucker a -> Plucker a -> Plucker a
max :: Plucker a -> Plucker a -> Plucker a
$cmax :: forall a. Ord a => Plucker a -> Plucker a -> Plucker a
>= :: Plucker a -> Plucker a -> Bool
$c>= :: forall a. Ord a => Plucker a -> Plucker a -> Bool
> :: Plucker a -> Plucker a -> Bool
$c> :: forall a. Ord a => Plucker a -> Plucker a -> Bool
<= :: Plucker a -> Plucker a -> Bool
$c<= :: forall a. Ord a => Plucker a -> Plucker a -> Bool
< :: Plucker a -> Plucker a -> Bool
$c< :: forall a. Ord a => Plucker a -> Plucker a -> Bool
compare :: Plucker a -> Plucker a -> Ordering
$ccompare :: forall a. Ord a => Plucker a -> Plucker a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Plucker a)
Ord,Int -> Plucker a -> ShowS
[Plucker a] -> ShowS
Plucker a -> String
(Int -> Plucker a -> ShowS)
-> (Plucker a -> String)
-> ([Plucker a] -> ShowS)
-> Show (Plucker a)
forall a. Show a => Int -> Plucker a -> ShowS
forall a. Show a => [Plucker a] -> ShowS
forall a. Show a => Plucker a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Plucker a] -> ShowS
$cshowList :: forall a. Show a => [Plucker a] -> ShowS
show :: Plucker a -> String
$cshow :: forall a. Show a => Plucker a -> String
showsPrec :: Int -> Plucker a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Plucker a -> ShowS
Show,ReadPrec [Plucker a]
ReadPrec (Plucker a)
Int -> ReadS (Plucker a)
ReadS [Plucker a]
(Int -> ReadS (Plucker a))
-> ReadS [Plucker a]
-> ReadPrec (Plucker a)
-> ReadPrec [Plucker a]
-> Read (Plucker a)
forall a. Read a => ReadPrec [Plucker a]
forall a. Read a => ReadPrec (Plucker a)
forall a. Read a => Int -> ReadS (Plucker a)
forall a. Read a => ReadS [Plucker a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Plucker a]
$creadListPrec :: forall a. Read a => ReadPrec [Plucker a]
readPrec :: ReadPrec (Plucker a)
$creadPrec :: forall a. Read a => ReadPrec (Plucker a)
readList :: ReadS [Plucker a]
$creadList :: forall a. Read a => ReadS [Plucker a]
readsPrec :: Int -> ReadS (Plucker a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Plucker a)
Read
,(forall x. Plucker a -> Rep (Plucker a) x)
-> (forall x. Rep (Plucker a) x -> Plucker a)
-> Generic (Plucker a)
forall x. Rep (Plucker a) x -> Plucker a
forall x. Plucker a -> Rep (Plucker a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Plucker a) x -> Plucker a
forall a x. Plucker a -> Rep (Plucker a) x
$cto :: forall a x. Rep (Plucker a) x -> Plucker a
$cfrom :: forall a x. Plucker a -> Rep (Plucker a) x
Generic,(forall a. Plucker a -> Rep1 Plucker a)
-> (forall a. Rep1 Plucker a -> Plucker a) -> Generic1 Plucker
forall a. Rep1 Plucker a -> Plucker a
forall a. Plucker a -> Rep1 Plucker a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 Plucker a -> Plucker a
$cfrom1 :: forall a. Plucker a -> Rep1 Plucker a
Generic1
#if defined(MIN_VERSION_template_haskell)
,Plucker a -> Q Exp
Plucker a -> Q (TExp (Plucker a))
(Plucker a -> Q Exp)
-> (Plucker a -> Q (TExp (Plucker a))) -> Lift (Plucker a)
forall a. Lift a => Plucker a -> Q Exp
forall a. Lift a => Plucker a -> Q (TExp (Plucker a))
forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t
liftTyped :: Plucker a -> Q (TExp (Plucker a))
$cliftTyped :: forall a. Lift a => Plucker a -> Q (TExp (Plucker a))
lift :: Plucker a -> Q Exp
$clift :: forall a. Lift a => Plucker a -> Q Exp
Lift
#endif
)
instance Finite Plucker where
type Size Plucker = 6
toV :: Plucker a -> V (Size Plucker) a
toV (Plucker a
a a
b a
c a
d a
e a
f) = Vector a -> V 6 a
forall k (n :: k) a. Vector a -> V n a
V (Int -> [a] -> Vector a
forall a. Int -> [a] -> Vector a
V.fromListN Int
6 [a
a,a
b,a
c,a
d,a
e,a
f])
fromV :: V (Size Plucker) a -> Plucker a
fromV (V Vector a
v) = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
0) (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
1) (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
2) (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
3) (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
4) (Vector a
v Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.! Int
5)
instance Random a => Random (Plucker a) where
random :: g -> (Plucker a, g)
random g
g = case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g of
(a
a, g
g1) -> case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g1 of
(a
b, g
g2) -> case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g2 of
(a
c, g
g3) -> case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g3 of
(a
d, g
g4) -> case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g4 of
(a
e, g
g5) -> case g -> (a, g)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g5 of
(a
f, g
g6) -> (a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d a
e a
f, g
g6)
randomR :: (Plucker a, Plucker a) -> g -> (Plucker a, g)
randomR (Plucker a
a a
b a
c a
d a
e a
f, Plucker a
a' a
b' a
c' a
d' a
e' a
f') g
g = case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
a,a
a') g
g of
(a
a'', g
g1) -> case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
b,a
b') g
g1 of
(a
b'', g
g2) -> case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
c,a
c') g
g2 of
(a
c'', g
g3) -> case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
d,a
d') g
g3 of
(a
d'', g
g4) -> case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
e,a
e') g
g4 of
(a
e'', g
g5) -> case (a, a) -> g -> (a, g)
forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
f,a
f') g
g5 of
(a
f'', g
g6) -> (a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a'' a
b'' a
c'' a
d'' a
e'' a
f'', g
g6)
instance Functor Plucker where
fmap :: (a -> b) -> Plucker a -> Plucker b
fmap a -> b
g (Plucker a
a a
b a
c a
d a
e a
f) = b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a -> b
g a
a) (a -> b
g a
b) (a -> b
g a
c) (a -> b
g a
d) (a -> b
g a
e) (a -> b
g a
f)
{-# INLINE fmap #-}
instance Apply Plucker where
Plucker a -> b
a a -> b
b a -> b
c a -> b
d a -> b
e a -> b
f <.> :: Plucker (a -> b) -> Plucker a -> Plucker b
<.> Plucker a
g a
h a
i a
j a
k a
l =
b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a -> b
a a
g) (a -> b
b a
h) (a -> b
c a
i) (a -> b
d a
j) (a -> b
e a
k) (a -> b
f a
l)
{-# INLINE (<.>) #-}
instance Applicative Plucker where
pure :: a -> Plucker a
pure a
a = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
a a
a a
a a
a a
a
{-# INLINE pure #-}
Plucker a -> b
a a -> b
b a -> b
c a -> b
d a -> b
e a -> b
f <*> :: Plucker (a -> b) -> Plucker a -> Plucker b
<*> Plucker a
g a
h a
i a
j a
k a
l =
b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a -> b
a a
g) (a -> b
b a
h) (a -> b
c a
i) (a -> b
d a
j) (a -> b
e a
k) (a -> b
f a
l)
{-# INLINE (<*>) #-}
instance Additive Plucker where
zero :: Plucker a
zero = a -> Plucker a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
0
{-# INLINE zero #-}
liftU2 :: (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
liftU2 = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
{-# INLINE liftU2 #-}
liftI2 :: (a -> b -> c) -> Plucker a -> Plucker b -> Plucker c
liftI2 = (a -> b -> c) -> Plucker a -> Plucker b -> Plucker c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
{-# INLINE liftI2 #-}
instance Bind Plucker where
Plucker a
a a
b a
c a
d a
e a
f >>- :: Plucker a -> (a -> Plucker b) -> Plucker b
>>- a -> Plucker b
g = b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker b
a' b
b' b
c' b
d' b
e' b
f' where
Plucker b
a' b
_ b
_ b
_ b
_ b
_ = a -> Plucker b
g a
a
Plucker b
_ b
b' b
_ b
_ b
_ b
_ = a -> Plucker b
g a
b
Plucker b
_ b
_ b
c' b
_ b
_ b
_ = a -> Plucker b
g a
c
Plucker b
_ b
_ b
_ b
d' b
_ b
_ = a -> Plucker b
g a
d
Plucker b
_ b
_ b
_ b
_ b
e' b
_ = a -> Plucker b
g a
e
Plucker b
_ b
_ b
_ b
_ b
_ b
f' = a -> Plucker b
g a
f
{-# INLINE (>>-) #-}
instance Monad Plucker where
#if !(MIN_VERSION_base(4,11,0))
return a = Plucker a a a a a a
{-# INLINE return #-}
#endif
Plucker a
a a
b a
c a
d a
e a
f >>= :: Plucker a -> (a -> Plucker b) -> Plucker b
>>= a -> Plucker b
g = b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker b
a' b
b' b
c' b
d' b
e' b
f' where
Plucker b
a' b
_ b
_ b
_ b
_ b
_ = a -> Plucker b
g a
a
Plucker b
_ b
b' b
_ b
_ b
_ b
_ = a -> Plucker b
g a
b
Plucker b
_ b
_ b
c' b
_ b
_ b
_ = a -> Plucker b
g a
c
Plucker b
_ b
_ b
_ b
d' b
_ b
_ = a -> Plucker b
g a
d
Plucker b
_ b
_ b
_ b
_ b
e' b
_ = a -> Plucker b
g a
e
Plucker b
_ b
_ b
_ b
_ b
_ b
f' = a -> Plucker b
g a
f
{-# INLINE (>>=) #-}
instance Distributive Plucker where
distribute :: f (Plucker a) -> Plucker (f a)
distribute f (Plucker a)
f = f a -> f a -> f a -> f a -> f a -> f a -> Plucker (f a)
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker ((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
x a
_ a
_ a
_ a
_ a
_) -> a
x) f (Plucker a)
f)
((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
_ a
x a
_ a
_ a
_ a
_) -> a
x) f (Plucker a)
f)
((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
_ a
_ a
x a
_ a
_ a
_) -> a
x) f (Plucker a)
f)
((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
_ a
_ a
_ a
x a
_ a
_) -> a
x) f (Plucker a)
f)
((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
_ a
_ a
_ a
_ a
x a
_) -> a
x) f (Plucker a)
f)
((Plucker a -> a) -> f (Plucker a) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Plucker a
_ a
_ a
_ a
_ a
_ a
x) -> a
x) f (Plucker a)
f)
{-# INLINE distribute #-}
instance Representable Plucker where
type Rep Plucker = E Plucker
tabulate :: (Rep Plucker -> a) -> Plucker a
tabulate Rep Plucker -> a
f = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (Rep Plucker -> a
f Rep Plucker
E Plucker
e01) (Rep Plucker -> a
f Rep Plucker
E Plucker
e02) (Rep Plucker -> a
f Rep Plucker
E Plucker
e03) (Rep Plucker -> a
f Rep Plucker
E Plucker
e23) (Rep Plucker -> a
f Rep Plucker
E Plucker
e31) (Rep Plucker -> a
f Rep Plucker
E Plucker
e12)
{-# INLINE tabulate #-}
index :: Plucker a -> Rep Plucker -> a
index Plucker a
xs (E l) = Getting a (Plucker a) a -> Plucker a -> a
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting a (Plucker a) a
forall x. Lens' (Plucker x) x
l Plucker a
xs
{-# INLINE index #-}
instance Foldable Plucker where
foldMap :: (a -> m) -> Plucker a -> m
foldMap a -> m
g (Plucker a
a a
b a
c a
d a
e a
f) =
a -> m
g a
a m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
g a
b m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
g a
c m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
g a
d m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
g a
e m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
g a
f
{-# INLINE foldMap #-}
null :: Plucker a -> Bool
null Plucker a
_ = Bool
False
length :: Plucker a -> Int
length Plucker a
_ = Int
6
instance Traversable Plucker where
traverse :: (a -> f b) -> Plucker a -> f (Plucker b)
traverse a -> f b
g (Plucker a
a a
b a
c a
d a
e a
f) =
b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (b -> b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
g a
a f (b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
g a
b f (b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
g a
c f (b -> b -> b -> Plucker b) -> f b -> f (b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
g a
d f (b -> b -> Plucker b) -> f b -> f (b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
g a
e f (b -> Plucker b) -> f b -> f (Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
g a
f
{-# INLINE traverse #-}
instance Foldable1 Plucker where
foldMap1 :: (a -> m) -> Plucker a -> m
foldMap1 a -> m
g (Plucker a
a a
b a
c a
d a
e a
f) =
a -> m
g a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
g a
b m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
g a
c m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
g a
d m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
g a
e m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
g a
f
{-# INLINE foldMap1 #-}
instance Traversable1 Plucker where
traverse1 :: (a -> f b) -> Plucker a -> f (Plucker b)
traverse1 a -> f b
g (Plucker a
a a
b a
c a
d a
e a
f) =
b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (b -> b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
g a
a f (b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> a -> f b
g a
b f (b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> a -> f b
g a
c f (b -> b -> b -> Plucker b) -> f b -> f (b -> b -> Plucker b)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> a -> f b
g a
d f (b -> b -> Plucker b) -> f b -> f (b -> Plucker b)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> a -> f b
g a
e f (b -> Plucker b) -> f b -> f (Plucker b)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> a -> f b
g a
f
{-# INLINE traverse1 #-}
instance Ix a => Ix (Plucker a) where
range :: (Plucker a, Plucker a) -> [Plucker a]
range (Plucker a
l1 a
l2 a
l3 a
l4 a
l5 a
l6,Plucker a
u1 a
u2 a
u3 a
u4 a
u5 a
u6) =
[a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
i1 a
i2 a
i3 a
i4 a
i5 a
i6 | a
i1 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l1,a
u1)
, a
i2 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l2,a
u2)
, a
i3 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l3,a
u3)
, a
i4 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l4,a
u4)
, a
i5 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l5,a
u5)
, a
i6 <- (a, a) -> [a]
forall a. Ix a => (a, a) -> [a]
range (a
l6,a
u6)
]
{-# INLINE range #-}
unsafeIndex :: (Plucker a, Plucker a) -> Plucker a -> Int
unsafeIndex (Plucker a
l1 a
l2 a
l3 a
l4 a
l5 a
l6,Plucker a
u1 a
u2 a
u3 a
u4 a
u5 a
u6) (Plucker a
i1 a
i2 a
i3 a
i4 a
i5 a
i6) =
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l6,a
u6) a
i6 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (a, a) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (a
l6,a
u6) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l5,a
u5) a
i5 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (a, a) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (a
l5,a
u5) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l4,a
u4) a
i4 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (a, a) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (a
l4,a
u4) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l3,a
u3) a
i3 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (a, a) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (a
l3,a
u3) Int -> Int -> Int
forall a. Num a => a -> a -> a
* (
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l2,a
u2) a
i2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (a, a) -> Int
forall a. Ix a => (a, a) -> Int
unsafeRangeSize (a
l2,a
u2) Int -> Int -> Int
forall a. Num a => a -> a -> a
*
(a, a) -> a -> Int
forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l1,a
u1) a
i1))))
{-# INLINE unsafeIndex #-}
inRange :: (Plucker a, Plucker a) -> Plucker a -> Bool
inRange (Plucker a
l1 a
l2 a
l3 a
l4 a
l5 a
l6,Plucker a
u1 a
u2 a
u3 a
u4 a
u5 a
u6) (Plucker a
i1 a
i2 a
i3 a
i4 a
i5 a
i6) =
(a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l1,a
u1) a
i1 Bool -> Bool -> Bool
&& (a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l2,a
u2) a
i2 Bool -> Bool -> Bool
&&
(a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l3,a
u3) a
i3 Bool -> Bool -> Bool
&& (a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l4,a
u4) a
i4 Bool -> Bool -> Bool
&&
(a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l5,a
u5) a
i5 Bool -> Bool -> Bool
&& (a, a) -> a -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l6,a
u6) a
i6
{-# INLINE inRange #-}
instance Num a => Num (Plucker a) where
+ :: Plucker a -> Plucker a -> Plucker a
(+) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(+)
{-# INLINE (+) #-}
(-) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (-)
{-# INLINE (-) #-}
* :: Plucker a -> Plucker a -> Plucker a
(*) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Num a => a -> a -> a
(*)
{-# INLINE (*) #-}
negate :: Plucker a -> Plucker a
negate = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
negate
{-# INLINE negate #-}
abs :: Plucker a -> Plucker a
abs = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
abs
{-# INLINE abs #-}
signum :: Plucker a -> Plucker a
signum = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
signum
{-# INLINE signum #-}
fromInteger :: Integer -> Plucker a
fromInteger = a -> Plucker a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Plucker a) -> (Integer -> a) -> Integer -> Plucker a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger
{-# INLINE fromInteger #-}
instance Fractional a => Fractional (Plucker a) where
recip :: Plucker a -> Plucker a
recip = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Fractional a => a -> a
recip
{-# INLINE recip #-}
/ :: Plucker a -> Plucker a -> Plucker a
(/) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Fractional a => a -> a -> a
(/)
{-# INLINE (/) #-}
fromRational :: Rational -> Plucker a
fromRational = a -> Plucker a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Plucker a) -> (Rational -> a) -> Rational -> Plucker a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> a
forall a. Fractional a => Rational -> a
fromRational
{-# INLINE fromRational #-}
instance Floating a => Floating (Plucker a) where
pi :: Plucker a
pi = a -> Plucker a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Floating a => a
pi
{-# INLINE pi #-}
exp :: Plucker a -> Plucker a
exp = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
exp
{-# INLINE exp #-}
sqrt :: Plucker a -> Plucker a
sqrt = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sqrt
{-# INLINE sqrt #-}
log :: Plucker a -> Plucker a
log = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
log
{-# INLINE log #-}
** :: Plucker a -> Plucker a -> Plucker a
(**) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Floating a => a -> a -> a
(**)
{-# INLINE (**) #-}
logBase :: Plucker a -> Plucker a -> Plucker a
logBase = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Floating a => a -> a -> a
logBase
{-# INLINE logBase #-}
sin :: Plucker a -> Plucker a
sin = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sin
{-# INLINE sin #-}
tan :: Plucker a -> Plucker a
tan = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
tan
{-# INLINE tan #-}
cos :: Plucker a -> Plucker a
cos = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
cos
{-# INLINE cos #-}
asin :: Plucker a -> Plucker a
asin = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
asin
{-# INLINE asin #-}
atan :: Plucker a -> Plucker a
atan = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
atan
{-# INLINE atan #-}
acos :: Plucker a -> Plucker a
acos = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
acos
{-# INLINE acos #-}
sinh :: Plucker a -> Plucker a
sinh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
sinh
{-# INLINE sinh #-}
tanh :: Plucker a -> Plucker a
tanh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
tanh
{-# INLINE tanh #-}
cosh :: Plucker a -> Plucker a
cosh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
cosh
{-# INLINE cosh #-}
asinh :: Plucker a -> Plucker a
asinh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
asinh
{-# INLINE asinh #-}
atanh :: Plucker a -> Plucker a
atanh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
atanh
{-# INLINE atanh #-}
acosh :: Plucker a -> Plucker a
acosh = (a -> a) -> Plucker a -> Plucker a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Floating a => a -> a
acosh
{-# INLINE acosh #-}
instance Hashable a => Hashable (Plucker a) where
hashWithSalt :: Int -> Plucker a -> Int
hashWithSalt Int
s (Plucker a
a a
b a
c a
d a
e a
f) = Int
s Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
a Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
b Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
c Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
d Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
e Int -> a -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
f
{-# INLINE hashWithSalt #-}
instance Storable a => Storable (Plucker a) where
sizeOf :: Plucker a -> Int
sizeOf Plucker a
_ = Int
6 Int -> Int -> Int
forall a. Num a => a -> a -> a
* a -> Int
forall a. Storable a => a -> Int
sizeOf (a
forall a. HasCallStack => a
undefined::a)
{-# INLINE sizeOf #-}
alignment :: Plucker a -> Int
alignment Plucker a
_ = a -> Int
forall a. Storable a => a -> Int
alignment (a
forall a. HasCallStack => a
undefined::a)
{-# INLINE alignment #-}
poke :: Ptr (Plucker a) -> Plucker a -> IO ()
poke Ptr (Plucker a)
ptr (Plucker a
a a
b a
c a
d a
e a
f) = do
Ptr a -> a -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr a
ptr' a
a
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr' Int
1 a
b
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr' Int
2 a
c
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr' Int
3 a
d
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr' Int
4 a
e
Ptr a -> Int -> a -> IO ()
forall a. Storable a => Ptr a -> Int -> a -> IO ()
pokeElemOff Ptr a
ptr' Int
5 a
f
where ptr' :: Ptr a
ptr' = Ptr (Plucker a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Plucker a)
ptr
{-# INLINE poke #-}
peek :: Ptr (Plucker a) -> IO (Plucker a)
peek Ptr (Plucker a)
ptr = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a -> a -> a -> a -> a -> a -> Plucker a)
-> IO a -> IO (a -> a -> a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr a -> IO a
forall a. Storable a => Ptr a -> IO a
peek Ptr a
ptr'
IO (a -> a -> a -> a -> a -> Plucker a)
-> IO a -> IO (a -> a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr' Int
1
IO (a -> a -> a -> a -> Plucker a)
-> IO a -> IO (a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr' Int
2
IO (a -> a -> a -> Plucker a) -> IO a -> IO (a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr' Int
3
IO (a -> a -> Plucker a) -> IO a -> IO (a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr' Int
4
IO (a -> Plucker a) -> IO a -> IO (Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr a -> Int -> IO a
forall a. Storable a => Ptr a -> Int -> IO a
peekElemOff Ptr a
ptr' Int
5
where ptr' :: Ptr a
ptr' = Ptr (Plucker a) -> Ptr a
forall a b. Ptr a -> Ptr b
castPtr Ptr (Plucker a)
ptr
{-# INLINE peek #-}
instance Metric Plucker where
dot :: Plucker a -> Plucker a -> a
dot (Plucker a
a a
b a
c a
d a
e a
f) (Plucker a
g a
h a
i a
j a
k a
l) = a
aa -> a -> a
forall a. Num a => a -> a -> a
*a
ga -> a -> a
forall a. Num a => a -> a -> a
+a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
ha -> a -> a
forall a. Num a => a -> a -> a
+a
ca -> a -> a
forall a. Num a => a -> a -> a
*a
ia -> a -> a
forall a. Num a => a -> a -> a
+a
da -> a -> a
forall a. Num a => a -> a -> a
*a
ja -> a -> a
forall a. Num a => a -> a -> a
+a
ea -> a -> a
forall a. Num a => a -> a -> a
*a
ka -> a -> a
forall a. Num a => a -> a -> a
+a
fa -> a -> a
forall a. Num a => a -> a -> a
*a
l
{-# INLINE dot #-}
instance Epsilon a => Epsilon (Plucker a) where
nearZero :: Plucker a -> Bool
nearZero = a -> Bool
forall a. Epsilon a => a -> Bool
nearZero (a -> Bool) -> (Plucker a -> a) -> Plucker a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Plucker a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> a
quadrance
{-# INLINE nearZero #-}
plucker :: Num a => V4 a -> V4 a -> Plucker a
plucker :: V4 a -> V4 a -> Plucker a
plucker (V4 a
a a
b a
c a
d)
(V4 a
e a
f a
g a
h) =
a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a
aa -> a -> a
forall a. Num a => a -> a -> a
*a
fa -> a -> a
forall a. Num a => a -> a -> a
-a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
e)
(a
aa -> a -> a
forall a. Num a => a -> a -> a
*a
ga -> a -> a
forall a. Num a => a -> a -> a
-a
ca -> a -> a
forall a. Num a => a -> a -> a
*a
e)
(a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
ga -> a -> a
forall a. Num a => a -> a -> a
-a
ca -> a -> a
forall a. Num a => a -> a -> a
*a
f)
(a
aa -> a -> a
forall a. Num a => a -> a -> a
*a
ha -> a -> a
forall a. Num a => a -> a -> a
-a
da -> a -> a
forall a. Num a => a -> a -> a
*a
e)
(a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
ha -> a -> a
forall a. Num a => a -> a -> a
-a
da -> a -> a
forall a. Num a => a -> a -> a
*a
f)
(a
ca -> a -> a
forall a. Num a => a -> a -> a
*a
ha -> a -> a
forall a. Num a => a -> a -> a
-a
da -> a -> a
forall a. Num a => a -> a -> a
*a
g)
{-# INLINE plucker #-}
plucker3D :: Num a => V3 a -> V3 a -> Plucker a
plucker3D :: V3 a -> V3 a -> Plucker a
plucker3D V3 a
p V3 a
q = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d a
e a
f
where V3 a
a a
b a
c = V3 a
p V3 a -> V3 a -> V3 a
forall a. Num a => a -> a -> a
- V3 a
q
V3 a
d a
e a
f = V3 a
p V3 a -> V3 a -> V3 a
forall a. Num a => V3 a -> V3 a -> V3 a
`cross` V3 a
q
p01, p02, p03, p23, p31, p12 :: Lens' (Plucker a) a
p01 :: (a -> f a) -> Plucker a -> f (Plucker a)
p01 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = (\a
a' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a' a
b a
c a
d a
e a
f) (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
a
p02 :: (a -> f a) -> Plucker a -> f (Plucker a)
p02 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = (\a
b' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b' a
c a
d a
e a
f) (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
b
p03 :: (a -> f a) -> Plucker a -> f (Plucker a)
p03 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = (\a
c' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c' a
d a
e a
f) (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
c
p23 :: (a -> f a) -> Plucker a -> f (Plucker a)
p23 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = (\a
d' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d' a
e a
f) (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
d
p31 :: (a -> f a) -> Plucker a -> f (Plucker a)
p31 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = (\a
e' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d a
e' a
f) (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
e
p12 :: (a -> f a) -> Plucker a -> f (Plucker a)
p12 a -> f a
g (Plucker a
a a
b a
c a
d a
e a
f) = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d a
e (a -> Plucker a) -> f a -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
g a
f
{-# INLINE p01 #-}
{-# INLINE p02 #-}
{-# INLINE p03 #-}
{-# INLINE p23 #-}
{-# INLINE p31 #-}
{-# INLINE p12 #-}
p10, p20, p30, p32, p13, p21 :: (Functor f, Num a) => (a -> f a) -> Plucker a -> f (Plucker a)
p10 :: (a -> f a) -> Plucker a -> f (Plucker a)
p10 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall x. Lens' (Plucker x) x
p01
p20 :: (a -> f a) -> Plucker a -> f (Plucker a)
p20 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall x. Lens' (Plucker x) x
p02
p30 :: (a -> f a) -> Plucker a -> f (Plucker a)
p30 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall x. Lens' (Plucker x) x
p03
p32 :: (a -> f a) -> Plucker a -> f (Plucker a)
p32 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall x. Lens' (Plucker x) x
p23
p13 :: (a -> f a) -> Plucker a -> f (Plucker a)
p13 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall x. Lens' (Plucker x) x
p31
p21 :: (a -> f a) -> Plucker a -> f (Plucker a)
p21 = ((a -> f a) -> Plucker a -> f (Plucker a))
-> (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a r.
(Functor f, Num a) =>
((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> Plucker a -> f (Plucker a)
forall (f :: * -> *) a.
(Functor f, Num a) =>
(a -> f a) -> Plucker a -> f (Plucker a)
p21
{-# INLINE p10 #-}
{-# INLINE p20 #-}
{-# INLINE p30 #-}
{-# INLINE p32 #-}
{-# INLINE p13 #-}
{-# INLINE p21 #-}
anti :: (Functor f, Num a) => ((a -> f a) -> r) -> (a -> f a) -> r
anti :: ((a -> f a) -> r) -> (a -> f a) -> r
anti (a -> f a) -> r
k a -> f a
f = (a -> f a) -> r
k ((a -> a) -> f a -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Num a => a -> a
negate (f a -> f a) -> (a -> f a) -> a -> f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
f (a -> f a) -> (a -> a) -> a -> f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
forall a. Num a => a -> a
negate)
e01, e02, e03, e23, e31, e12 :: E Plucker
e01 :: E Plucker
e01 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p01
e02 :: E Plucker
e02 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p02
e03 :: E Plucker
e03 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p03
e23 :: E Plucker
e23 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p23
e31 :: E Plucker
e31 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p31
e12 :: E Plucker
e12 = (forall x. Lens' (Plucker x) x) -> E Plucker
forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall x. Lens' (Plucker x) x
p12
instance WithIndex.FunctorWithIndex (E Plucker) Plucker where
imap :: (E Plucker -> a -> b) -> Plucker a -> Plucker b
imap E Plucker -> a -> b
f (Plucker a
a a
b a
c a
d a
e a
g) = b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (E Plucker -> a -> b
f E Plucker
e01 a
a) (E Plucker -> a -> b
f E Plucker
e02 a
b) (E Plucker -> a -> b
f E Plucker
e03 a
c) (E Plucker -> a -> b
f E Plucker
e23 a
d) (E Plucker -> a -> b
f E Plucker
e31 a
e) (E Plucker -> a -> b
f E Plucker
e12 a
g)
{-# INLINE imap #-}
instance WithIndex.FoldableWithIndex (E Plucker) Plucker where
ifoldMap :: (E Plucker -> a -> m) -> Plucker a -> m
ifoldMap E Plucker -> a -> m
f (Plucker a
a a
b a
c a
d a
e a
g) = E Plucker -> a -> m
f E Plucker
e01 a
a m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` E Plucker -> a -> m
f E Plucker
e02 a
b m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` E Plucker -> a -> m
f E Plucker
e03 a
c
m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` E Plucker -> a -> m
f E Plucker
e23 a
d m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` E Plucker -> a -> m
f E Plucker
e31 a
e m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` E Plucker -> a -> m
f E Plucker
e12 a
g
{-# INLINE ifoldMap #-}
instance WithIndex.TraversableWithIndex (E Plucker) Plucker where
itraverse :: (E Plucker -> a -> f b) -> Plucker a -> f (Plucker b)
itraverse E Plucker -> a -> f b
f (Plucker a
a a
b a
c a
d a
e a
g) = b -> b -> b -> b -> b -> b -> Plucker b
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (b -> b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> E Plucker -> a -> f b
f E Plucker
e01 a
a f (b -> b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> E Plucker -> a -> f b
f E Plucker
e02 a
b f (b -> b -> b -> b -> Plucker b)
-> f b -> f (b -> b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> E Plucker -> a -> f b
f E Plucker
e03 a
c
f (b -> b -> b -> Plucker b) -> f b -> f (b -> b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> E Plucker -> a -> f b
f E Plucker
e23 a
d f (b -> b -> Plucker b) -> f b -> f (b -> Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> E Plucker -> a -> f b
f E Plucker
e31 a
e f (b -> Plucker b) -> f b -> f (Plucker b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> E Plucker -> a -> f b
f E Plucker
e12 a
g
{-# INLINE itraverse #-}
#if !MIN_VERSION_lens(5,0,0)
instance Lens.FunctorWithIndex (E Plucker) Plucker where imap = WithIndex.imap
instance Lens.FoldableWithIndex (E Plucker) Plucker where ifoldMap = WithIndex.ifoldMap
instance Lens.TraversableWithIndex (E Plucker) Plucker where itraverse = WithIndex.itraverse
#endif
type instance Index (Plucker a) = E Plucker
type instance IxValue (Plucker a) = a
instance Ixed (Plucker a) where
ix :: Index (Plucker a) -> Traversal' (Plucker a) (IxValue (Plucker a))
ix Index (Plucker a)
i = E Plucker -> forall x. Lens' (Plucker x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el Index (Plucker a)
E Plucker
i
{-# INLINE ix #-}
instance Each (Plucker a) (Plucker b) a b where
each :: (a -> f b) -> Plucker a -> f (Plucker b)
each = (a -> f b) -> Plucker a -> f (Plucker b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
{-# INLINE each #-}
squaredError :: Num a => Plucker a -> a
squaredError :: Plucker a -> a
squaredError Plucker a
v = Plucker a
v Plucker a -> Plucker a -> a
forall a. Num a => Plucker a -> Plucker a -> a
>< Plucker a
v
{-# INLINE squaredError #-}
infixl 5 ><
(><) :: Num a => Plucker a -> Plucker a -> a
Plucker a
a a
b a
c a
d a
e a
f >< :: Plucker a -> Plucker a -> a
>< Plucker a
g a
h a
i a
j a
k a
l = a
aa -> a -> a
forall a. Num a => a -> a -> a
*a
la -> a -> a
forall a. Num a => a -> a -> a
-a
ba -> a -> a
forall a. Num a => a -> a -> a
*a
ka -> a -> a
forall a. Num a => a -> a -> a
+a
ca -> a -> a
forall a. Num a => a -> a -> a
*a
ja -> a -> a
forall a. Num a => a -> a -> a
+a
da -> a -> a
forall a. Num a => a -> a -> a
*a
ia -> a -> a
forall a. Num a => a -> a -> a
-a
ea -> a -> a
forall a. Num a => a -> a -> a
*a
ha -> a -> a
forall a. Num a => a -> a -> a
+a
fa -> a -> a
forall a. Num a => a -> a -> a
*a
g
{-# INLINE (><) #-}
isotropic :: Epsilon a => Plucker a -> Bool
isotropic :: Plucker a -> Bool
isotropic Plucker a
a = a -> Bool
forall a. Epsilon a => a -> Bool
nearZero (Plucker a
a Plucker a -> Plucker a -> a
forall a. Num a => Plucker a -> Plucker a -> a
>< Plucker a
a)
{-# INLINE isotropic #-}
intersects :: (Epsilon a, Ord a) => Plucker a -> Plucker a -> Bool
intersects :: Plucker a -> Plucker a -> Bool
intersects Plucker a
a Plucker a
b = Bool -> Bool
not (Plucker a
a Plucker a -> Plucker a -> Bool
forall a. Epsilon a => Plucker a -> Plucker a -> Bool
`parallel` Plucker a
b) Bool -> Bool -> Bool
&& Plucker a -> Plucker a -> LinePass
forall a. (Epsilon a, Ord a) => Plucker a -> Plucker a -> LinePass
passes Plucker a
a Plucker a
b LinePass -> LinePass -> Bool
forall a. Eq a => a -> a -> Bool
== LinePass
Coplanar
{-# INLINE intersects #-}
data LinePass = Coplanar
| Clockwise
| Counterclockwise
deriving (LinePass -> LinePass -> Bool
(LinePass -> LinePass -> Bool)
-> (LinePass -> LinePass -> Bool) -> Eq LinePass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinePass -> LinePass -> Bool
$c/= :: LinePass -> LinePass -> Bool
== :: LinePass -> LinePass -> Bool
$c== :: LinePass -> LinePass -> Bool
Eq, Int -> LinePass -> ShowS
[LinePass] -> ShowS
LinePass -> String
(Int -> LinePass -> ShowS)
-> (LinePass -> String) -> ([LinePass] -> ShowS) -> Show LinePass
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LinePass] -> ShowS
$cshowList :: [LinePass] -> ShowS
show :: LinePass -> String
$cshow :: LinePass -> String
showsPrec :: Int -> LinePass -> ShowS
$cshowsPrec :: Int -> LinePass -> ShowS
Show,(forall x. LinePass -> Rep LinePass x)
-> (forall x. Rep LinePass x -> LinePass) -> Generic LinePass
forall x. Rep LinePass x -> LinePass
forall x. LinePass -> Rep LinePass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LinePass x -> LinePass
$cfrom :: forall x. LinePass -> Rep LinePass x
Generic)
passes :: (Epsilon a, Ord a) => Plucker a -> Plucker a -> LinePass
passes :: Plucker a -> Plucker a -> LinePass
passes Plucker a
a Plucker a
b
| a -> Bool
forall a. Epsilon a => a -> Bool
nearZero a
s = LinePass
Coplanar
| a
s a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
0 = LinePass
Counterclockwise
| Bool
otherwise = LinePass
Clockwise
where s :: a
s = (V3 a
u1 V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
v2) a -> a -> a
forall a. Num a => a -> a -> a
+ (V3 a
u2 V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
v1)
V2 V3 a
u1 V3 a
v1 = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
a
V2 V3 a
u2 V3 a
v2 = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
b
{-# INLINE passes #-}
parallel :: Epsilon a => Plucker a -> Plucker a -> Bool
parallel :: Plucker a -> Plucker a -> Bool
parallel Plucker a
a Plucker a
b = V3 a -> Bool
forall a. Epsilon a => a -> Bool
nearZero (V3 a -> Bool) -> V3 a -> Bool
forall a b. (a -> b) -> a -> b
$ V3 a
u1 V3 a -> V3 a -> V3 a
forall a. Num a => V3 a -> V3 a -> V3 a
`cross` V3 a
u2
where V2 V3 a
u1 V3 a
_ = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
a
V2 V3 a
u2 V3 a
_ = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
b
{-# INLINE parallel #-}
toUV :: Plucker a -> V2 (V3 a)
toUV :: Plucker a -> V2 (V3 a)
toUV (Plucker a
a a
b a
c a
d a
e a
f) = V3 a -> V3 a -> V2 (V3 a)
forall a. a -> a -> V2 a
V2 (a -> a -> a -> V3 a
forall a. a -> a -> a -> V3 a
V3 a
a a
b a
c) (a -> a -> a -> V3 a
forall a. a -> a -> a -> V3 a
V3 a
d a
e a
f)
coincides :: (Epsilon a, Fractional a) => Plucker a -> Plucker a -> Bool
coincides :: Plucker a -> Plucker a -> Bool
coincides Plucker a
p1 Plucker a
p2 = (a -> Bool) -> Plucker a -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Foldable.all a -> Bool
forall a. Epsilon a => a -> Bool
nearZero (Plucker a -> Bool) -> Plucker a -> Bool
forall a b. (a -> b) -> a -> b
$ (a
s a -> Plucker a -> Plucker a
forall (f :: * -> *) a. (Functor f, Num a) => a -> f a -> f a
*^ Plucker a
p2) Plucker a -> Plucker a -> Plucker a
forall a. Num a => a -> a -> a
- Plucker a
p1
where s :: a
s = a -> (First a -> a) -> Maybe (First a) -> a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe a
1 First a -> a
forall a. First a -> a
getFirst (Maybe (First a) -> a)
-> (Plucker (Maybe (First a)) -> Maybe (First a))
-> Plucker (Maybe (First a))
-> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (First a) -> Maybe (First a)
forall a. OptionCompat a -> OptionCompat a
getOptionCompat (Maybe (First a) -> Maybe (First a))
-> (Plucker (Maybe (First a)) -> Maybe (First a))
-> Plucker (Maybe (First a))
-> Maybe (First a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Plucker (Maybe (First a)) -> Maybe (First a)
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Plucker (Maybe (First a)) -> a) -> Plucker (Maybe (First a)) -> a
forall a b. (a -> b) -> a -> b
$ a -> a -> Maybe (First a)
forall a.
(Epsilon a, Fractional a) =>
a -> a -> OptionCompat (First a)
saveDiv (a -> a -> Maybe (First a))
-> Plucker a -> Plucker (a -> Maybe (First a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Plucker a
p1 Plucker (a -> Maybe (First a))
-> Plucker a -> Plucker (Maybe (First a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Plucker a
p2
saveDiv :: a -> a -> OptionCompat (First a)
saveDiv a
x a
y | a -> Bool
forall a. Epsilon a => a -> Bool
nearZero a
y = OptionCompat (First a) -> OptionCompat (First a)
forall a. OptionCompat a -> OptionCompat a
optionCompat OptionCompat (First a)
forall a. Maybe a
Nothing
| Bool
otherwise = OptionCompat (First a) -> OptionCompat (First a)
forall a. OptionCompat a -> OptionCompat a
optionCompat (OptionCompat (First a) -> OptionCompat (First a))
-> (First a -> OptionCompat (First a))
-> First a
-> OptionCompat (First a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> OptionCompat (First a)
forall a. a -> Maybe a
Just (First a -> OptionCompat (First a))
-> First a -> OptionCompat (First a)
forall a b. (a -> b) -> a -> b
$ a -> First a
forall a. a -> First a
First (a
x a -> a -> a
forall a. Fractional a => a -> a -> a
/ a
y)
{-# INLINABLE coincides #-}
coincides' :: (Epsilon a, Fractional a, Ord a) => Plucker a -> Plucker a -> Bool
coincides' :: Plucker a -> Plucker a -> Bool
coincides' Plucker a
p1 Plucker a
p2 = (a -> Bool) -> Plucker a -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Foldable.all a -> Bool
forall a. Epsilon a => a -> Bool
nearZero ((a
s a -> Plucker a -> Plucker a
forall (f :: * -> *) a. (Functor f, Num a) => a -> f a -> f a
*^ Plucker a
p2) Plucker a -> Plucker a -> Plucker a
forall a. Num a => a -> a -> a
- Plucker a
p1) Bool -> Bool -> Bool
&& a
s a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
0
where s :: a
s = a -> (First a -> a) -> Maybe (First a) -> a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe a
1 First a -> a
forall a. First a -> a
getFirst (Maybe (First a) -> a)
-> (Plucker (Maybe (First a)) -> Maybe (First a))
-> Plucker (Maybe (First a))
-> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (First a) -> Maybe (First a)
forall a. OptionCompat a -> OptionCompat a
getOptionCompat (Maybe (First a) -> Maybe (First a))
-> (Plucker (Maybe (First a)) -> Maybe (First a))
-> Plucker (Maybe (First a))
-> Maybe (First a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Plucker (Maybe (First a)) -> Maybe (First a)
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Plucker (Maybe (First a)) -> a) -> Plucker (Maybe (First a)) -> a
forall a b. (a -> b) -> a -> b
$ a -> a -> Maybe (First a)
forall a.
(Epsilon a, Fractional a) =>
a -> a -> OptionCompat (First a)
saveDiv (a -> a -> Maybe (First a))
-> Plucker a -> Plucker (a -> Maybe (First a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Plucker a
p1 Plucker (a -> Maybe (First a))
-> Plucker a -> Plucker (Maybe (First a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Plucker a
p2
saveDiv :: a -> a -> OptionCompat (First a)
saveDiv a
x a
y | a -> Bool
forall a. Epsilon a => a -> Bool
nearZero a
y = OptionCompat (First a) -> OptionCompat (First a)
forall a. OptionCompat a -> OptionCompat a
optionCompat OptionCompat (First a)
forall a. Maybe a
Nothing
| Bool
otherwise = OptionCompat (First a) -> OptionCompat (First a)
forall a. OptionCompat a -> OptionCompat a
optionCompat (OptionCompat (First a) -> OptionCompat (First a))
-> (First a -> OptionCompat (First a))
-> First a
-> OptionCompat (First a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> OptionCompat (First a)
forall a. a -> Maybe a
Just (First a -> OptionCompat (First a))
-> First a -> OptionCompat (First a)
forall a b. (a -> b) -> a -> b
$ a -> First a
forall a. a -> First a
First (a
x a -> a -> a
forall a. Fractional a => a -> a -> a
/ a
y)
{-# INLINABLE coincides' #-}
#if MIN_VERSION_base(4,11,0)
type OptionCompat = Maybe
optionCompat :: Maybe a -> OptionCompat a
optionCompat :: Maybe a -> Maybe a
optionCompat = Maybe a -> Maybe a
forall a. a -> a
id
getOptionCompat :: OptionCompat a -> Maybe a
getOptionCompat :: OptionCompat a -> OptionCompat a
getOptionCompat = OptionCompat a -> OptionCompat a
forall a. a -> a
id
#else
type OptionCompat = Option
optionCompat :: Maybe a -> OptionCompat a
optionCompat = Option
getOptionCompat :: OptionCompat a -> Maybe a
getOptionCompat = getOption
#endif
quadranceToOrigin :: Fractional a => Plucker a -> a
quadranceToOrigin :: Plucker a -> a
quadranceToOrigin Plucker a
p = (V3 a
v V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
v) a -> a -> a
forall a. Fractional a => a -> a -> a
/ (V3 a
u V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
u)
where V2 V3 a
u V3 a
v = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
p
{-# INLINE quadranceToOrigin #-}
closestToOrigin :: Fractional a => Plucker a -> V3 a
closestToOrigin :: Plucker a -> V3 a
closestToOrigin Plucker a
p = V4 a -> V3 a
forall a. Fractional a => V4 a -> V3 a
normalizePoint (V4 a -> V3 a) -> V4 a -> V3 a
forall a b. (a -> b) -> a -> b
$ a -> a -> a -> a -> V4 a
forall a. a -> a -> a -> a -> V4 a
V4 a
x a
y a
z (V3 a
u V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
u)
where V2 V3 a
u V3 a
v = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
p
V3 a
x a
y a
z = V3 a
v V3 a -> V3 a -> V3 a
forall a. Num a => V3 a -> V3 a -> V3 a
`cross` V3 a
u
{-# INLINE closestToOrigin #-}
isLine :: Epsilon a => Plucker a -> Bool
isLine :: Plucker a -> Bool
isLine Plucker a
p = a -> Bool
forall a. Epsilon a => a -> Bool
nearZero (a -> Bool) -> a -> Bool
forall a b. (a -> b) -> a -> b
$ V3 a
u V3 a -> V3 a -> a
forall (f :: * -> *) a. (Metric f, Num a) => f a -> f a -> a
`dot` V3 a
v
where V2 V3 a
u V3 a
v = Plucker a -> V2 (V3 a)
forall a. Plucker a -> V2 (V3 a)
toUV Plucker a
p
{-# INLINE isLine #-}
data instance U.Vector (Plucker a) = V_Plucker !Int (U.Vector a)
data instance U.MVector s (Plucker a) = MV_Plucker !Int (U.MVector s a)
instance U.Unbox a => U.Unbox (Plucker a)
instance U.Unbox a => M.MVector U.MVector (Plucker a) where
basicLength :: MVector s (Plucker a) -> Int
basicLength (MV_Plucker n _) = Int
n
basicUnsafeSlice :: Int -> Int -> MVector s (Plucker a) -> MVector s (Plucker a)
basicUnsafeSlice Int
m Int
n (MV_Plucker _ v) = Int -> MVector s a -> MVector s (Plucker a)
forall s a. Int -> MVector s a -> MVector s (Plucker a)
MV_Plucker Int
n (Int -> Int -> MVector s a -> MVector s a
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
M.basicUnsafeSlice (Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
m) (Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n) MVector s a
v)
basicOverlaps :: MVector s (Plucker a) -> MVector s (Plucker a) -> Bool
basicOverlaps (MV_Plucker _ v) (MV_Plucker _ u) = MVector s a -> MVector s a -> Bool
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> Bool
M.basicOverlaps MVector s a
v MVector s a
u
basicUnsafeNew :: Int -> m (MVector (PrimState m) (Plucker a))
basicUnsafeNew Int
n = (MVector (PrimState m) a -> MVector (PrimState m) (Plucker a))
-> m (MVector (PrimState m) a)
-> m (MVector (PrimState m) (Plucker a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> MVector (PrimState m) a -> MVector (PrimState m) (Plucker a)
forall s a. Int -> MVector s a -> MVector s (Plucker a)
MV_Plucker Int
n) (Int -> m (MVector (PrimState m) a)
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
Int -> m (v (PrimState m) a)
M.basicUnsafeNew (Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n))
basicUnsafeRead :: MVector (PrimState m) (Plucker a) -> Int -> m (Plucker a)
basicUnsafeRead (MV_Plucker _ a) Int
i =
do let o :: Int
o = Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
i
a
x <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a Int
o
a
y <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
a
z <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
2)
a
w <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
3)
a
v <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
4)
a
u <- MVector (PrimState m) a -> Int -> m a
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> m a
M.basicUnsafeRead MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
5)
Plucker a -> m (Plucker a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z a
w a
v a
u)
basicUnsafeWrite :: MVector (PrimState m) (Plucker a) -> Int -> Plucker a -> m ()
basicUnsafeWrite (MV_Plucker _ a) Int
i (Plucker a
x a
y a
z a
w a
v a
u) =
do let o :: Int
o = Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
i
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a Int
o a
x
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1) a
y
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
2) a
z
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
3) a
w
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
4) a
v
MVector (PrimState m) a -> Int -> a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> Int -> a -> m ()
M.basicUnsafeWrite MVector (PrimState m) a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
5) a
u
basicInitialize :: MVector (PrimState m) (Plucker a) -> m ()
basicInitialize (MV_Plucker _ v) = MVector (PrimState m) a -> m ()
forall (v :: * -> * -> *) a (m :: * -> *).
(MVector v a, PrimMonad m) =>
v (PrimState m) a -> m ()
M.basicInitialize MVector (PrimState m) a
v
instance U.Unbox a => G.Vector U.Vector (Plucker a) where
basicUnsafeFreeze :: Mutable Vector (PrimState m) (Plucker a) -> m (Vector (Plucker a))
basicUnsafeFreeze (MV_Plucker n v) = (Vector a -> Vector (Plucker a))
-> m (Vector a) -> m (Vector (Plucker a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ( Int -> Vector a -> Vector (Plucker a)
forall a. Int -> Vector a -> Vector (Plucker a)
V_Plucker Int
n) (Mutable Vector (PrimState m) a -> m (Vector a)
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, PrimMonad m) =>
Mutable v (PrimState m) a -> m (v a)
G.basicUnsafeFreeze MVector (PrimState m) a
Mutable Vector (PrimState m) a
v)
basicUnsafeThaw :: Vector (Plucker a) -> m (Mutable Vector (PrimState m) (Plucker a))
basicUnsafeThaw ( V_Plucker n v) = (MVector (PrimState m) a -> MVector (PrimState m) (Plucker a))
-> m (MVector (PrimState m) a)
-> m (MVector (PrimState m) (Plucker a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> MVector (PrimState m) a -> MVector (PrimState m) (Plucker a)
forall s a. Int -> MVector s a -> MVector s (Plucker a)
MV_Plucker Int
n) (Vector a -> m (Mutable Vector (PrimState m) a)
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, PrimMonad m) =>
v a -> m (Mutable v (PrimState m) a)
G.basicUnsafeThaw Vector a
v)
basicLength :: Vector (Plucker a) -> Int
basicLength ( V_Plucker n _) = Int
n
basicUnsafeSlice :: Int -> Int -> Vector (Plucker a) -> Vector (Plucker a)
basicUnsafeSlice Int
m Int
n (V_Plucker _ v) = Int -> Vector a -> Vector (Plucker a)
forall a. Int -> Vector a -> Vector (Plucker a)
V_Plucker Int
n (Int -> Int -> Vector a -> Vector a
forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
G.basicUnsafeSlice (Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
m) (Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n) Vector a
v)
basicUnsafeIndexM :: Vector (Plucker a) -> Int -> m (Plucker a)
basicUnsafeIndexM (V_Plucker _ a) Int
i =
do let o :: Int
o = Int
6Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
i
a
x <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a Int
o
a
y <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
a
z <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
2)
a
w <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
3)
a
v <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
4)
a
u <- Vector a -> Int -> m a
forall (v :: * -> *) a (m :: * -> *).
(Vector v a, Monad m) =>
v a -> Int -> m a
G.basicUnsafeIndexM Vector a
a (Int
oInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
5)
Plucker a -> m (Plucker a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z a
w a
v a
u)
instance MonadZip Plucker where
mzipWith :: (a -> b -> c) -> Plucker a -> Plucker b -> Plucker c
mzipWith = (a -> b -> c) -> Plucker a -> Plucker b -> Plucker c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
instance MonadFix Plucker where
mfix :: (a -> Plucker a) -> Plucker a
mfix a -> Plucker a
f = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (let Plucker a
a a
_ a
_ a
_ a
_ a
_ = a -> Plucker a
f a
a in a
a)
(let Plucker a
_ a
a a
_ a
_ a
_ a
_ = a -> Plucker a
f a
a in a
a)
(let Plucker a
_ a
_ a
a a
_ a
_ a
_ = a -> Plucker a
f a
a in a
a)
(let Plucker a
_ a
_ a
_ a
a a
_ a
_ = a -> Plucker a
f a
a in a
a)
(let Plucker a
_ a
_ a
_ a
_ a
a a
_ = a -> Plucker a
f a
a in a
a)
(let Plucker a
_ a
_ a
_ a
_ a
_ a
a = a -> Plucker a
f a
a in a
a)
instance NFData a => NFData (Plucker a) where
rnf :: Plucker a -> ()
rnf (Plucker a
a a
b a
c a
d a
e a
f) = a -> ()
forall a. NFData a => a -> ()
rnf a
a () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
b () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
c
() -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
d () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
e () -> () -> ()
`seq` a -> ()
forall a. NFData a => a -> ()
rnf a
f
instance Serial1 Plucker where
serializeWith :: (a -> m ()) -> Plucker a -> m ()
serializeWith = (a -> m ()) -> Plucker a -> m ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_
deserializeWith :: m a -> m (Plucker a)
deserializeWith m a
k = a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker (a -> a -> a -> a -> a -> a -> Plucker a)
-> m a -> m (a -> a -> a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
k m (a -> a -> a -> a -> a -> Plucker a)
-> m a -> m (a -> a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
k m (a -> a -> a -> a -> Plucker a)
-> m a -> m (a -> a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
k m (a -> a -> a -> Plucker a) -> m a -> m (a -> a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
k m (a -> a -> Plucker a) -> m a -> m (a -> Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
k m (a -> Plucker a) -> m a -> m (Plucker a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m a
k
instance Serial a => Serial (Plucker a) where
serialize :: Plucker a -> m ()
serialize = (a -> m ()) -> Plucker a -> m ()
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
serializeWith a -> m ()
forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
serialize
deserialize :: m (Plucker a)
deserialize = m a -> m (Plucker a)
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadGet m) =>
m a -> m (f a)
deserializeWith m a
forall a (m :: * -> *). (Serial a, MonadGet m) => m a
deserialize
instance Binary a => Binary (Plucker a) where
put :: Plucker a -> Put
put = (a -> Put) -> Plucker a -> Put
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
serializeWith a -> Put
forall t. Binary t => t -> Put
Binary.put
get :: Get (Plucker a)
get = Get a -> Get (Plucker a)
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadGet m) =>
m a -> m (f a)
deserializeWith Get a
forall t. Binary t => Get t
Binary.get
instance Serialize a => Serialize (Plucker a) where
put :: Putter (Plucker a)
put = (a -> PutM ()) -> Putter (Plucker a)
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
serializeWith a -> PutM ()
forall t. Serialize t => Putter t
Cereal.put
get :: Get (Plucker a)
get = Get a -> Get (Plucker a)
forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadGet m) =>
m a -> m (f a)
deserializeWith Get a
forall t. Serialize t => Get t
Cereal.get
instance Eq1 Plucker where
liftEq :: (a -> b -> Bool) -> Plucker a -> Plucker b -> Bool
liftEq a -> b -> Bool
k (Plucker a
a1 a
b1 a
c1 a
d1 a
e1 a
f1)
(Plucker b
a2 b
b2 b
c2 b
d2 b
e2 b
f2)
= a -> b -> Bool
k a
a1 b
a2 Bool -> Bool -> Bool
&& a -> b -> Bool
k a
b1 b
b2 Bool -> Bool -> Bool
&& a -> b -> Bool
k a
c1 b
c2 Bool -> Bool -> Bool
&& a -> b -> Bool
k a
d1 b
d2 Bool -> Bool -> Bool
&& a -> b -> Bool
k a
e1 b
e2 Bool -> Bool -> Bool
&& a -> b -> Bool
k a
f1 b
f2
instance Ord1 Plucker where
liftCompare :: (a -> b -> Ordering) -> Plucker a -> Plucker b -> Ordering
liftCompare a -> b -> Ordering
k (Plucker a
a1 a
b1 a
c1 a
d1 a
e1 a
f1)
(Plucker b
a2 b
b2 b
c2 b
d2 b
e2 b
f2)
= a -> b -> Ordering
k a
a1 b
a2 Ordering -> Ordering -> Ordering
forall a. Monoid a => a -> a -> a
`mappend` a -> b -> Ordering
k a
b1 b
b2 Ordering -> Ordering -> Ordering
forall a. Monoid a => a -> a -> a
`mappend` a -> b -> Ordering
k a
c1 b
c2 Ordering -> Ordering -> Ordering
forall a. Monoid a => a -> a -> a
`mappend` a -> b -> Ordering
k a
d1 b
d2 Ordering -> Ordering -> Ordering
forall a. Monoid a => a -> a -> a
`mappend` a -> b -> Ordering
k a
e1 b
e2 Ordering -> Ordering -> Ordering
forall a. Monoid a => a -> a -> a
`mappend` a -> b -> Ordering
k a
f1 b
f2
instance Read1 Plucker where
liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Plucker a)
liftReadsPrec Int -> ReadS a
k ReadS [a]
_ Int
z = Bool -> ReadS (Plucker a) -> ReadS (Plucker a)
forall a. Bool -> ReadS a -> ReadS a
readParen (Int
z Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ReadS (Plucker a) -> ReadS (Plucker a))
-> ReadS (Plucker a) -> ReadS (Plucker a)
forall a b. (a -> b) -> a -> b
$ \String
r ->
[ (a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
a a
b a
c a
d a
e a
f, String
r7)
| (String
"Plucker",String
r1) <- ReadS String
lex String
r
, (a
a,String
r2) <- Int -> ReadS a
k Int
11 String
r1
, (a
b,String
r3) <- Int -> ReadS a
k Int
11 String
r2
, (a
c,String
r4) <- Int -> ReadS a
k Int
11 String
r3
, (a
d,String
r5) <- Int -> ReadS a
k Int
11 String
r4
, (a
e,String
r6) <- Int -> ReadS a
k Int
11 String
r5
, (a
f,String
r7) <- Int -> ReadS a
k Int
11 String
r6
]
instance Show1 Plucker where
liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Plucker a -> ShowS
liftShowsPrec Int -> a -> ShowS
k [a] -> ShowS
_ Int
z (Plucker a
a a
b a
c a
d a
e a
f) = Bool -> ShowS -> ShowS
showParen (Int
z Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"Plucker " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
a ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
b ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
c ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
d ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
e ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
k Int
11 a
f
instance Field1 (Plucker a) (Plucker a) a a where
_1 :: (a -> f a) -> Plucker a -> f (Plucker a)
_1 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
x f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
x' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x' a
y a
z a
u a
v a
w
instance Field2 (Plucker a) (Plucker a) a a where
_2 :: (a -> f a) -> Plucker a -> f (Plucker a)
_2 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
y f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
y' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y' a
z a
u a
v a
w
instance Field3 (Plucker a) (Plucker a) a a where
_3 :: (a -> f a) -> Plucker a -> f (Plucker a)
_3 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
z f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
z' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z' a
u a
v a
w
instance Field4 (Plucker a) (Plucker a) a a where
_4 :: (a -> f a) -> Plucker a -> f (Plucker a)
_4 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
u f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
u' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z a
u' a
v a
w
instance Field5 (Plucker a) (Plucker a) a a where
_5 :: (a -> f a) -> Plucker a -> f (Plucker a)
_5 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
v f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
v' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z a
u a
v' a
w
instance Field6 (Plucker a) (Plucker a) a a where
_6 :: (a -> f a) -> Plucker a -> f (Plucker a)
_6 a -> f a
f (Plucker a
x a
y a
z a
u a
v a
w) = a -> f a
f a
w f a -> (a -> Plucker a) -> f (Plucker a)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \a
w' -> a -> a -> a -> a -> a -> a -> Plucker a
forall a. a -> a -> a -> a -> a -> a -> Plucker a
Plucker a
x a
y a
z a
u a
v a
w'
instance Semigroup a => Semigroup (Plucker a) where
<> :: Plucker a -> Plucker a -> Plucker a
(<>) = (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semigroup a => a -> a -> a
(<>)
instance Monoid a => Monoid (Plucker a) where
mempty :: Plucker a
mempty = a -> Plucker a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Monoid a => a
mempty
#if !(MIN_VERSION_base(4,11,0))
mappend = liftA2 mappend
#endif