module HGeometry.Boundary
( Boundary(..)
, _Boundary
, PointLocationResult(..)
, PointLocationResultWith(..)
, asPointLocationResult
) where
import Control.Lens (iso,Iso)
import HGeometry.Properties
newtype Boundary g = Boundary g
deriving (Int -> Boundary g -> ShowS
[Boundary g] -> ShowS
Boundary g -> String
(Int -> Boundary g -> ShowS)
-> (Boundary g -> String)
-> ([Boundary g] -> ShowS)
-> Show (Boundary g)
forall g. Show g => Int -> Boundary g -> ShowS
forall g. Show g => [Boundary g] -> ShowS
forall g. Show g => Boundary g -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall g. Show g => Int -> Boundary g -> ShowS
showsPrec :: Int -> Boundary g -> ShowS
$cshow :: forall g. Show g => Boundary g -> String
show :: Boundary g -> String
$cshowList :: forall g. Show g => [Boundary g] -> ShowS
showList :: [Boundary g] -> ShowS
Show,Boundary g -> Boundary g -> Bool
(Boundary g -> Boundary g -> Bool)
-> (Boundary g -> Boundary g -> Bool) -> Eq (Boundary g)
forall g. Eq g => Boundary g -> Boundary g -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall g. Eq g => Boundary g -> Boundary g -> Bool
== :: Boundary g -> Boundary g -> Bool
$c/= :: forall g. Eq g => Boundary g -> Boundary g -> Bool
/= :: Boundary g -> Boundary g -> Bool
Eq,Eq (Boundary g)
Eq (Boundary g) =>
(Boundary g -> Boundary g -> Ordering)
-> (Boundary g -> Boundary g -> Bool)
-> (Boundary g -> Boundary g -> Bool)
-> (Boundary g -> Boundary g -> Bool)
-> (Boundary g -> Boundary g -> Bool)
-> (Boundary g -> Boundary g -> Boundary g)
-> (Boundary g -> Boundary g -> Boundary g)
-> Ord (Boundary g)
Boundary g -> Boundary g -> Bool
Boundary g -> Boundary g -> Ordering
Boundary g -> Boundary g -> Boundary g
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 g. Ord g => Eq (Boundary g)
forall g. Ord g => Boundary g -> Boundary g -> Bool
forall g. Ord g => Boundary g -> Boundary g -> Ordering
forall g. Ord g => Boundary g -> Boundary g -> Boundary g
$ccompare :: forall g. Ord g => Boundary g -> Boundary g -> Ordering
compare :: Boundary g -> Boundary g -> Ordering
$c< :: forall g. Ord g => Boundary g -> Boundary g -> Bool
< :: Boundary g -> Boundary g -> Bool
$c<= :: forall g. Ord g => Boundary g -> Boundary g -> Bool
<= :: Boundary g -> Boundary g -> Bool
$c> :: forall g. Ord g => Boundary g -> Boundary g -> Bool
> :: Boundary g -> Boundary g -> Bool
$c>= :: forall g. Ord g => Boundary g -> Boundary g -> Bool
>= :: Boundary g -> Boundary g -> Bool
$cmax :: forall g. Ord g => Boundary g -> Boundary g -> Boundary g
max :: Boundary g -> Boundary g -> Boundary g
$cmin :: forall g. Ord g => Boundary g -> Boundary g -> Boundary g
min :: Boundary g -> Boundary g -> Boundary g
Ord,ReadPrec [Boundary g]
ReadPrec (Boundary g)
Int -> ReadS (Boundary g)
ReadS [Boundary g]
(Int -> ReadS (Boundary g))
-> ReadS [Boundary g]
-> ReadPrec (Boundary g)
-> ReadPrec [Boundary g]
-> Read (Boundary g)
forall g. Read g => ReadPrec [Boundary g]
forall g. Read g => ReadPrec (Boundary g)
forall g. Read g => Int -> ReadS (Boundary g)
forall g. Read g => ReadS [Boundary g]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall g. Read g => Int -> ReadS (Boundary g)
readsPrec :: Int -> ReadS (Boundary g)
$creadList :: forall g. Read g => ReadS [Boundary g]
readList :: ReadS [Boundary g]
$creadPrec :: forall g. Read g => ReadPrec (Boundary g)
readPrec :: ReadPrec (Boundary g)
$creadListPrec :: forall g. Read g => ReadPrec [Boundary g]
readListPrec :: ReadPrec [Boundary g]
Read
,(forall a b. (a -> b) -> Boundary a -> Boundary b)
-> (forall a b. a -> Boundary b -> Boundary a) -> Functor Boundary
forall a b. a -> Boundary b -> Boundary a
forall a b. (a -> b) -> Boundary a -> Boundary b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Boundary a -> Boundary b
fmap :: forall a b. (a -> b) -> Boundary a -> Boundary b
$c<$ :: forall a b. a -> Boundary b -> Boundary a
<$ :: forall a b. a -> Boundary b -> Boundary a
Functor,(forall m. Monoid m => Boundary m -> m)
-> (forall m a. Monoid m => (a -> m) -> Boundary a -> m)
-> (forall m a. Monoid m => (a -> m) -> Boundary a -> m)
-> (forall a b. (a -> b -> b) -> b -> Boundary a -> b)
-> (forall a b. (a -> b -> b) -> b -> Boundary a -> b)
-> (forall b a. (b -> a -> b) -> b -> Boundary a -> b)
-> (forall b a. (b -> a -> b) -> b -> Boundary a -> b)
-> (forall a. (a -> a -> a) -> Boundary a -> a)
-> (forall a. (a -> a -> a) -> Boundary a -> a)
-> (forall a. Boundary a -> [a])
-> (forall a. Boundary a -> Bool)
-> (forall a. Boundary a -> Int)
-> (forall a. Eq a => a -> Boundary a -> Bool)
-> (forall a. Ord a => Boundary a -> a)
-> (forall a. Ord a => Boundary a -> a)
-> (forall a. Num a => Boundary a -> a)
-> (forall a. Num a => Boundary a -> a)
-> Foldable Boundary
forall a. Eq a => a -> Boundary a -> Bool
forall a. Num a => Boundary a -> a
forall a. Ord a => Boundary a -> a
forall m. Monoid m => Boundary m -> m
forall a. Boundary a -> Bool
forall a. Boundary a -> Int
forall a. Boundary a -> [a]
forall a. (a -> a -> a) -> Boundary a -> a
forall m a. Monoid m => (a -> m) -> Boundary a -> m
forall b a. (b -> a -> b) -> b -> Boundary a -> b
forall a b. (a -> b -> b) -> b -> Boundary a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Boundary m -> m
fold :: forall m. Monoid m => Boundary m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Boundary a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Boundary a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Boundary a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Boundary a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Boundary a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Boundary a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Boundary a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Boundary a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Boundary a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Boundary a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Boundary a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Boundary a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Boundary a -> a
foldr1 :: forall a. (a -> a -> a) -> Boundary a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Boundary a -> a
foldl1 :: forall a. (a -> a -> a) -> Boundary a -> a
$ctoList :: forall a. Boundary a -> [a]
toList :: forall a. Boundary a -> [a]
$cnull :: forall a. Boundary a -> Bool
null :: forall a. Boundary a -> Bool
$clength :: forall a. Boundary a -> Int
length :: forall a. Boundary a -> Int
$celem :: forall a. Eq a => a -> Boundary a -> Bool
elem :: forall a. Eq a => a -> Boundary a -> Bool
$cmaximum :: forall a. Ord a => Boundary a -> a
maximum :: forall a. Ord a => Boundary a -> a
$cminimum :: forall a. Ord a => Boundary a -> a
minimum :: forall a. Ord a => Boundary a -> a
$csum :: forall a. Num a => Boundary a -> a
sum :: forall a. Num a => Boundary a -> a
$cproduct :: forall a. Num a => Boundary a -> a
product :: forall a. Num a => Boundary a -> a
Foldable,Functor Boundary
Foldable Boundary
(Functor Boundary, Foldable Boundary) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Boundary a -> f (Boundary b))
-> (forall (f :: * -> *) a.
Applicative f =>
Boundary (f a) -> f (Boundary a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Boundary a -> m (Boundary b))
-> (forall (m :: * -> *) a.
Monad m =>
Boundary (m a) -> m (Boundary a))
-> Traversable Boundary
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Boundary (m a) -> m (Boundary a)
forall (f :: * -> *) a.
Applicative f =>
Boundary (f a) -> f (Boundary a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Boundary a -> m (Boundary b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Boundary a -> f (Boundary b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Boundary a -> f (Boundary b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Boundary a -> f (Boundary b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Boundary (f a) -> f (Boundary a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Boundary (f a) -> f (Boundary a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Boundary a -> m (Boundary b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Boundary a -> m (Boundary b)
$csequence :: forall (m :: * -> *) a. Monad m => Boundary (m a) -> m (Boundary a)
sequence :: forall (m :: * -> *) a. Monad m => Boundary (m a) -> m (Boundary a)
Traversable)
type instance NumType (Boundary g) = NumType g
type instance Dimension (Boundary g) = Dimension g
_Boundary :: Iso g h (Boundary g) (Boundary h)
_Boundary :: forall g h (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (Boundary g) (f (Boundary h)) -> p g (f h)
_Boundary = (g -> Boundary g)
-> (Boundary h -> h) -> Iso g h (Boundary g) (Boundary h)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso g -> Boundary g
forall g. g -> Boundary g
Boundary (\(Boundary h
b) -> h
b)
data PointLocationResult = Inside
| OnBoundary
| Outside
deriving (Int -> PointLocationResult -> ShowS
[PointLocationResult] -> ShowS
PointLocationResult -> String
(Int -> PointLocationResult -> ShowS)
-> (PointLocationResult -> String)
-> ([PointLocationResult] -> ShowS)
-> Show PointLocationResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PointLocationResult -> ShowS
showsPrec :: Int -> PointLocationResult -> ShowS
$cshow :: PointLocationResult -> String
show :: PointLocationResult -> String
$cshowList :: [PointLocationResult] -> ShowS
showList :: [PointLocationResult] -> ShowS
Show,ReadPrec [PointLocationResult]
ReadPrec PointLocationResult
Int -> ReadS PointLocationResult
ReadS [PointLocationResult]
(Int -> ReadS PointLocationResult)
-> ReadS [PointLocationResult]
-> ReadPrec PointLocationResult
-> ReadPrec [PointLocationResult]
-> Read PointLocationResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PointLocationResult
readsPrec :: Int -> ReadS PointLocationResult
$creadList :: ReadS [PointLocationResult]
readList :: ReadS [PointLocationResult]
$creadPrec :: ReadPrec PointLocationResult
readPrec :: ReadPrec PointLocationResult
$creadListPrec :: ReadPrec [PointLocationResult]
readListPrec :: ReadPrec [PointLocationResult]
Read,PointLocationResult -> PointLocationResult -> Bool
(PointLocationResult -> PointLocationResult -> Bool)
-> (PointLocationResult -> PointLocationResult -> Bool)
-> Eq PointLocationResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PointLocationResult -> PointLocationResult -> Bool
== :: PointLocationResult -> PointLocationResult -> Bool
$c/= :: PointLocationResult -> PointLocationResult -> Bool
/= :: PointLocationResult -> PointLocationResult -> Bool
Eq)
data PointLocationResultWith edge = StrictlyInside
| OnBoundaryEdge !edge
| StrictlyOutside
deriving (Int -> PointLocationResultWith edge -> ShowS
[PointLocationResultWith edge] -> ShowS
PointLocationResultWith edge -> String
(Int -> PointLocationResultWith edge -> ShowS)
-> (PointLocationResultWith edge -> String)
-> ([PointLocationResultWith edge] -> ShowS)
-> Show (PointLocationResultWith edge)
forall edge.
Show edge =>
Int -> PointLocationResultWith edge -> ShowS
forall edge. Show edge => [PointLocationResultWith edge] -> ShowS
forall edge. Show edge => PointLocationResultWith edge -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall edge.
Show edge =>
Int -> PointLocationResultWith edge -> ShowS
showsPrec :: Int -> PointLocationResultWith edge -> ShowS
$cshow :: forall edge. Show edge => PointLocationResultWith edge -> String
show :: PointLocationResultWith edge -> String
$cshowList :: forall edge. Show edge => [PointLocationResultWith edge] -> ShowS
showList :: [PointLocationResultWith edge] -> ShowS
Show,ReadPrec [PointLocationResultWith edge]
ReadPrec (PointLocationResultWith edge)
Int -> ReadS (PointLocationResultWith edge)
ReadS [PointLocationResultWith edge]
(Int -> ReadS (PointLocationResultWith edge))
-> ReadS [PointLocationResultWith edge]
-> ReadPrec (PointLocationResultWith edge)
-> ReadPrec [PointLocationResultWith edge]
-> Read (PointLocationResultWith edge)
forall edge. Read edge => ReadPrec [PointLocationResultWith edge]
forall edge. Read edge => ReadPrec (PointLocationResultWith edge)
forall edge.
Read edge =>
Int -> ReadS (PointLocationResultWith edge)
forall edge. Read edge => ReadS [PointLocationResultWith edge]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall edge.
Read edge =>
Int -> ReadS (PointLocationResultWith edge)
readsPrec :: Int -> ReadS (PointLocationResultWith edge)
$creadList :: forall edge. Read edge => ReadS [PointLocationResultWith edge]
readList :: ReadS [PointLocationResultWith edge]
$creadPrec :: forall edge. Read edge => ReadPrec (PointLocationResultWith edge)
readPrec :: ReadPrec (PointLocationResultWith edge)
$creadListPrec :: forall edge. Read edge => ReadPrec [PointLocationResultWith edge]
readListPrec :: ReadPrec [PointLocationResultWith edge]
Read,PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
(PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool)
-> (PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool)
-> Eq (PointLocationResultWith edge)
forall edge.
Eq edge =>
PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall edge.
Eq edge =>
PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
== :: PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
$c/= :: forall edge.
Eq edge =>
PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
/= :: PointLocationResultWith edge
-> PointLocationResultWith edge -> Bool
Eq,(forall a b.
(a -> b) -> PointLocationResultWith a -> PointLocationResultWith b)
-> (forall a b.
a -> PointLocationResultWith b -> PointLocationResultWith a)
-> Functor PointLocationResultWith
forall a b.
a -> PointLocationResultWith b -> PointLocationResultWith a
forall a b.
(a -> b) -> PointLocationResultWith a -> PointLocationResultWith b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b.
(a -> b) -> PointLocationResultWith a -> PointLocationResultWith b
fmap :: forall a b.
(a -> b) -> PointLocationResultWith a -> PointLocationResultWith b
$c<$ :: forall a b.
a -> PointLocationResultWith b -> PointLocationResultWith a
<$ :: forall a b.
a -> PointLocationResultWith b -> PointLocationResultWith a
Functor)
asPointLocationResult :: PointLocationResultWith edge -> PointLocationResult
asPointLocationResult :: forall edge. PointLocationResultWith edge -> PointLocationResult
asPointLocationResult = \case
PointLocationResultWith edge
StrictlyInside -> PointLocationResult
Inside
OnBoundaryEdge edge
_ -> PointLocationResult
OnBoundary
PointLocationResultWith edge
StrictlyOutside -> PointLocationResult
Outside