{-# LANGUAGE UndecidableInstances #-}
module HGeometry.HalfSpace.Type
( HalfSpaceF(..), HalfPlaneF
, HalfSpace
, Sign(..)
, module HGeometry.HalfSpace.Class
, Point_x_HalfSpace_Intersection(..)
, boundingHyperPlaneLens
) where
import Control.Lens
import Data.Bifoldable
import Data.Bifoldable1
import Data.Bitraversable
import Data.Semigroup.Bitraversable
import HGeometry.HalfSpace.Class
import HGeometry.HyperPlane
import HGeometry.Intersection
import HGeometry.Point
import HGeometry.Properties (NumType,Dimension)
import HGeometry.Sign
import HGeometry.Vector
import GHC.TypeNats
data HalfSpaceF boundingHyperPlane =
HalfSpace {-# UNPACK #-} !Sign boundingHyperPlane
deriving (Int -> HalfSpaceF boundingHyperPlane -> ShowS
[HalfSpaceF boundingHyperPlane] -> ShowS
HalfSpaceF boundingHyperPlane -> String
(Int -> HalfSpaceF boundingHyperPlane -> ShowS)
-> (HalfSpaceF boundingHyperPlane -> String)
-> ([HalfSpaceF boundingHyperPlane] -> ShowS)
-> Show (HalfSpaceF boundingHyperPlane)
forall boundingHyperPlane.
Show boundingHyperPlane =>
Int -> HalfSpaceF boundingHyperPlane -> ShowS
forall boundingHyperPlane.
Show boundingHyperPlane =>
[HalfSpaceF boundingHyperPlane] -> ShowS
forall boundingHyperPlane.
Show boundingHyperPlane =>
HalfSpaceF boundingHyperPlane -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall boundingHyperPlane.
Show boundingHyperPlane =>
Int -> HalfSpaceF boundingHyperPlane -> ShowS
showsPrec :: Int -> HalfSpaceF boundingHyperPlane -> ShowS
$cshow :: forall boundingHyperPlane.
Show boundingHyperPlane =>
HalfSpaceF boundingHyperPlane -> String
show :: HalfSpaceF boundingHyperPlane -> String
$cshowList :: forall boundingHyperPlane.
Show boundingHyperPlane =>
[HalfSpaceF boundingHyperPlane] -> ShowS
showList :: [HalfSpaceF boundingHyperPlane] -> ShowS
Show,HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
(HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> Eq (HalfSpaceF boundingHyperPlane)
forall boundingHyperPlane.
Eq boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall boundingHyperPlane.
Eq boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
== :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
$c/= :: forall boundingHyperPlane.
Eq boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
/= :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
Eq,Eq (HalfSpaceF boundingHyperPlane)
Eq (HalfSpaceF boundingHyperPlane) =>
(HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Ordering)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane)
-> (HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane)
-> Ord (HalfSpaceF boundingHyperPlane)
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Ordering
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
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 boundingHyperPlane.
Ord boundingHyperPlane =>
Eq (HalfSpaceF boundingHyperPlane)
forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Ordering
forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
$ccompare :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Ordering
compare :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Ordering
$c< :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
< :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
$c<= :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
<= :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
$c> :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
> :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
$c>= :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
>= :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> Bool
$cmax :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
max :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
$cmin :: forall boundingHyperPlane.
Ord boundingHyperPlane =>
HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
min :: HalfSpaceF boundingHyperPlane
-> HalfSpaceF boundingHyperPlane -> HalfSpaceF boundingHyperPlane
Ord,(forall a b. (a -> b) -> HalfSpaceF a -> HalfSpaceF b)
-> (forall a b. a -> HalfSpaceF b -> HalfSpaceF a)
-> Functor HalfSpaceF
forall a b. a -> HalfSpaceF b -> HalfSpaceF a
forall a b. (a -> b) -> HalfSpaceF a -> HalfSpaceF 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) -> HalfSpaceF a -> HalfSpaceF b
fmap :: forall a b. (a -> b) -> HalfSpaceF a -> HalfSpaceF b
$c<$ :: forall a b. a -> HalfSpaceF b -> HalfSpaceF a
<$ :: forall a b. a -> HalfSpaceF b -> HalfSpaceF a
Functor,(forall m. Monoid m => HalfSpaceF m -> m)
-> (forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m)
-> (forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m)
-> (forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b)
-> (forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b)
-> (forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b)
-> (forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b)
-> (forall a. (a -> a -> a) -> HalfSpaceF a -> a)
-> (forall a. (a -> a -> a) -> HalfSpaceF a -> a)
-> (forall a. HalfSpaceF a -> [a])
-> (forall a. HalfSpaceF a -> Bool)
-> (forall a. HalfSpaceF a -> Int)
-> (forall a. Eq a => a -> HalfSpaceF a -> Bool)
-> (forall a. Ord a => HalfSpaceF a -> a)
-> (forall a. Ord a => HalfSpaceF a -> a)
-> (forall a. Num a => HalfSpaceF a -> a)
-> (forall a. Num a => HalfSpaceF a -> a)
-> Foldable HalfSpaceF
forall a. Eq a => a -> HalfSpaceF a -> Bool
forall a. Num a => HalfSpaceF a -> a
forall a. Ord a => HalfSpaceF a -> a
forall m. Monoid m => HalfSpaceF m -> m
forall a. HalfSpaceF a -> Bool
forall a. HalfSpaceF a -> Int
forall a. HalfSpaceF a -> [a]
forall a. (a -> a -> a) -> HalfSpaceF a -> a
forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m
forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b
forall a b. (a -> b -> b) -> b -> HalfSpaceF 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 => HalfSpaceF m -> m
fold :: forall m. Monoid m => HalfSpaceF m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> HalfSpaceF a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b
foldr :: forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> HalfSpaceF a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b
foldl :: forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> HalfSpaceF a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> HalfSpaceF a -> a
foldr1 :: forall a. (a -> a -> a) -> HalfSpaceF a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> HalfSpaceF a -> a
foldl1 :: forall a. (a -> a -> a) -> HalfSpaceF a -> a
$ctoList :: forall a. HalfSpaceF a -> [a]
toList :: forall a. HalfSpaceF a -> [a]
$cnull :: forall a. HalfSpaceF a -> Bool
null :: forall a. HalfSpaceF a -> Bool
$clength :: forall a. HalfSpaceF a -> Int
length :: forall a. HalfSpaceF a -> Int
$celem :: forall a. Eq a => a -> HalfSpaceF a -> Bool
elem :: forall a. Eq a => a -> HalfSpaceF a -> Bool
$cmaximum :: forall a. Ord a => HalfSpaceF a -> a
maximum :: forall a. Ord a => HalfSpaceF a -> a
$cminimum :: forall a. Ord a => HalfSpaceF a -> a
minimum :: forall a. Ord a => HalfSpaceF a -> a
$csum :: forall a. Num a => HalfSpaceF a -> a
sum :: forall a. Num a => HalfSpaceF a -> a
$cproduct :: forall a. Num a => HalfSpaceF a -> a
product :: forall a. Num a => HalfSpaceF a -> a
Foldable,Functor HalfSpaceF
Foldable HalfSpaceF
(Functor HalfSpaceF, Foldable HalfSpaceF) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HalfSpaceF a -> f (HalfSpaceF b))
-> (forall (f :: * -> *) a.
Applicative f =>
HalfSpaceF (f a) -> f (HalfSpaceF a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HalfSpaceF a -> m (HalfSpaceF b))
-> (forall (m :: * -> *) a.
Monad m =>
HalfSpaceF (m a) -> m (HalfSpaceF a))
-> Traversable HalfSpaceF
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 =>
HalfSpaceF (m a) -> m (HalfSpaceF a)
forall (f :: * -> *) a.
Applicative f =>
HalfSpaceF (f a) -> f (HalfSpaceF a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HalfSpaceF a -> m (HalfSpaceF b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HalfSpaceF a -> f (HalfSpaceF b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HalfSpaceF a -> f (HalfSpaceF b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HalfSpaceF a -> f (HalfSpaceF b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
HalfSpaceF (f a) -> f (HalfSpaceF a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
HalfSpaceF (f a) -> f (HalfSpaceF a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HalfSpaceF a -> m (HalfSpaceF b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HalfSpaceF a -> m (HalfSpaceF b)
$csequence :: forall (m :: * -> *) a.
Monad m =>
HalfSpaceF (m a) -> m (HalfSpaceF a)
sequence :: forall (m :: * -> *) a.
Monad m =>
HalfSpaceF (m a) -> m (HalfSpaceF a)
Traversable)
instance ( NumType boundingHyperPlane ~ r
, Dimension boundingHyperPlane ~ d
) => HalfSpace_ (HalfSpaceF boundingHyperPlane) d r where
type BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r = boundingHyperPlane
halfSpaceSign :: Lens' (HalfSpaceF boundingHyperPlane) Sign
halfSpaceSign = (HalfSpaceF boundingHyperPlane -> Sign)
-> (HalfSpaceF boundingHyperPlane
-> Sign -> HalfSpaceF boundingHyperPlane)
-> Lens' (HalfSpaceF boundingHyperPlane) Sign
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(HalfSpace Sign
s boundingHyperPlane
_) -> Sign
s) (\(HalfSpace Sign
_ boundingHyperPlane
h) Sign
s -> Sign -> boundingHyperPlane -> HalfSpaceF boundingHyperPlane
forall boundingHyperPlane.
Sign -> boundingHyperPlane -> HalfSpaceF boundingHyperPlane
HalfSpace Sign
s boundingHyperPlane
h)
{-# INLINE halfSpaceSign #-}
boundingHyperPlane :: Lens'
(HalfSpaceF boundingHyperPlane)
(BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r)
boundingHyperPlane = (boundingHyperPlane -> f boundingHyperPlane)
-> HalfSpaceF boundingHyperPlane
-> f (HalfSpaceF boundingHyperPlane)
(BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r
-> f (BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r))
-> HalfSpaceF boundingHyperPlane
-> f (HalfSpaceF boundingHyperPlane)
forall boundingHyperPlane boundingHyperPlane' (f :: * -> *).
Functor f =>
(boundingHyperPlane -> f boundingHyperPlane')
-> HalfSpaceF boundingHyperPlane
-> f (HalfSpaceF boundingHyperPlane')
boundingHyperPlaneLens
boundingHyperPlaneLens :: Lens (HalfSpaceF boundingHyperPlane) (HalfSpaceF boundingHyperPlane')
boundingHyperPlane boundingHyperPlane'
boundingHyperPlaneLens :: forall boundingHyperPlane boundingHyperPlane' (f :: * -> *).
Functor f =>
(boundingHyperPlane -> f boundingHyperPlane')
-> HalfSpaceF boundingHyperPlane
-> f (HalfSpaceF boundingHyperPlane')
boundingHyperPlaneLens = (HalfSpaceF boundingHyperPlane -> boundingHyperPlane)
-> (HalfSpaceF boundingHyperPlane
-> boundingHyperPlane' -> HalfSpaceF boundingHyperPlane')
-> Lens
(HalfSpaceF boundingHyperPlane)
(HalfSpaceF boundingHyperPlane')
boundingHyperPlane
boundingHyperPlane'
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(HalfSpace Sign
_ boundingHyperPlane
h) -> boundingHyperPlane
h) (\(HalfSpace Sign
s boundingHyperPlane
_) boundingHyperPlane'
h -> Sign -> boundingHyperPlane' -> HalfSpaceF boundingHyperPlane'
forall boundingHyperPlane.
Sign -> boundingHyperPlane -> HalfSpaceF boundingHyperPlane
HalfSpace Sign
s boundingHyperPlane'
h)
{-# INLINE boundingHyperPlaneLens #-}
type HalfSpace d r = HalfSpaceF (HyperPlane d r)
type HalfPlaneF line = HalfSpaceF line
type instance Dimension (HalfSpaceF boundingHyperPlane) = Dimension boundingHyperPlane
type instance NumType (HalfSpaceF boundingHyperPlane) = NumType boundingHyperPlane
instance ( HyperPlane_ boudingHyperPlane d r, Ord r, Num r
, Has_ Additive_ d r
) => HasIntersectionWith (Point d r) (HalfSpaceF boudingHyperPlane)
type instance Intersection (Point d r) (HalfSpaceF boudingHyperPlane) =
Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
data Point_x_HalfSpace_Intersection boundaryPoint interiorPoint =
Point_x_HalfSpace_OnBoundary boundaryPoint
| Point_x_HalfSpace_Interior interiorPoint
deriving (Int
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> ShowS
[Point_x_HalfSpace_Intersection boundaryPoint interiorPoint]
-> ShowS
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> String
(Int
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> ShowS)
-> (Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> String)
-> ([Point_x_HalfSpace_Intersection boundaryPoint interiorPoint]
-> ShowS)
-> Show
(Point_x_HalfSpace_Intersection boundaryPoint interiorPoint)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
Int
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> ShowS
forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
[Point_x_HalfSpace_Intersection boundaryPoint interiorPoint]
-> ShowS
forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> String
$cshowsPrec :: forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
Int
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> ShowS
showsPrec :: Int
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> ShowS
$cshow :: forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> String
show :: Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> String
$cshowList :: forall boundaryPoint interiorPoint.
(Show boundaryPoint, Show interiorPoint) =>
[Point_x_HalfSpace_Intersection boundaryPoint interiorPoint]
-> ShowS
showList :: [Point_x_HalfSpace_Intersection boundaryPoint interiorPoint]
-> ShowS
Show,Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
(Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool)
-> (Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool)
-> Eq (Point_x_HalfSpace_Intersection boundaryPoint interiorPoint)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall boundaryPoint interiorPoint.
(Eq boundaryPoint, Eq interiorPoint) =>
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
$c== :: forall boundaryPoint interiorPoint.
(Eq boundaryPoint, Eq interiorPoint) =>
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
== :: Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
$c/= :: forall boundaryPoint interiorPoint.
(Eq boundaryPoint, Eq interiorPoint) =>
Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
/= :: Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
-> Bool
Eq,(forall a b.
(a -> b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> Point_x_HalfSpace_Intersection boundaryPoint b)
-> (forall a b.
a
-> Point_x_HalfSpace_Intersection boundaryPoint b
-> Point_x_HalfSpace_Intersection boundaryPoint a)
-> Functor (Point_x_HalfSpace_Intersection boundaryPoint)
forall a b.
a
-> Point_x_HalfSpace_Intersection boundaryPoint b
-> Point_x_HalfSpace_Intersection boundaryPoint a
forall a b.
(a -> b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> Point_x_HalfSpace_Intersection boundaryPoint b
forall boundaryPoint a b.
a
-> Point_x_HalfSpace_Intersection boundaryPoint b
-> Point_x_HalfSpace_Intersection boundaryPoint a
forall boundaryPoint a b.
(a -> b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> Point_x_HalfSpace_Intersection boundaryPoint b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall boundaryPoint a b.
(a -> b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> Point_x_HalfSpace_Intersection boundaryPoint b
fmap :: forall a b.
(a -> b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> Point_x_HalfSpace_Intersection boundaryPoint b
$c<$ :: forall boundaryPoint a b.
a
-> Point_x_HalfSpace_Intersection boundaryPoint b
-> Point_x_HalfSpace_Intersection boundaryPoint a
<$ :: forall a b.
a
-> Point_x_HalfSpace_Intersection boundaryPoint b
-> Point_x_HalfSpace_Intersection boundaryPoint a
Functor,(forall m.
Monoid m =>
Point_x_HalfSpace_Intersection boundaryPoint m -> m)
-> (forall m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m)
-> (forall m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m)
-> (forall a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b)
-> (forall a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b)
-> (forall b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b)
-> (forall b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b)
-> (forall a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> (forall a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> (forall a.
Point_x_HalfSpace_Intersection boundaryPoint a -> [a])
-> (forall a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Bool)
-> (forall a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Int)
-> (forall a.
Eq a =>
a -> Point_x_HalfSpace_Intersection boundaryPoint a -> Bool)
-> (forall a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> (forall a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> (forall a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> (forall a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a)
-> Foldable (Point_x_HalfSpace_Intersection boundaryPoint)
forall a.
Eq a =>
a -> Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
forall a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall m.
Monoid m =>
Point_x_HalfSpace_Intersection boundaryPoint m -> m
forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> Int
forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> [a]
forall a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall boundaryPoint a.
Eq a =>
a -> Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
forall boundaryPoint a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall boundaryPoint a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall boundaryPoint m.
Monoid m =>
Point_x_HalfSpace_Intersection boundaryPoint m -> m
forall m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Int
forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> [a]
forall b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
forall a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
forall boundaryPoint a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
forall boundaryPoint m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
forall boundaryPoint b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
forall boundaryPoint a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint 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 boundaryPoint m.
Monoid m =>
Point_x_HalfSpace_Intersection boundaryPoint m -> m
fold :: forall m.
Monoid m =>
Point_x_HalfSpace_Intersection boundaryPoint m -> m
$cfoldMap :: forall boundaryPoint m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
foldMap :: forall m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
$cfoldMap' :: forall boundaryPoint m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
foldMap' :: forall m a.
Monoid m =>
(a -> m) -> Point_x_HalfSpace_Intersection boundaryPoint a -> m
$cfoldr :: forall boundaryPoint a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
foldr :: forall a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
$cfoldr' :: forall boundaryPoint a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
foldr' :: forall a b.
(a -> b -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
$cfoldl :: forall boundaryPoint b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
foldl :: forall b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
$cfoldl' :: forall boundaryPoint b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
foldl' :: forall b a.
(b -> a -> b)
-> b -> Point_x_HalfSpace_Intersection boundaryPoint a -> b
$cfoldr1 :: forall boundaryPoint a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
foldr1 :: forall a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
$cfoldl1 :: forall boundaryPoint a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
foldl1 :: forall a.
(a -> a -> a)
-> Point_x_HalfSpace_Intersection boundaryPoint a -> a
$ctoList :: forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> [a]
toList :: forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> [a]
$cnull :: forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
null :: forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
$clength :: forall boundaryPoint a.
Point_x_HalfSpace_Intersection boundaryPoint a -> Int
length :: forall a. Point_x_HalfSpace_Intersection boundaryPoint a -> Int
$celem :: forall boundaryPoint a.
Eq a =>
a -> Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
elem :: forall a.
Eq a =>
a -> Point_x_HalfSpace_Intersection boundaryPoint a -> Bool
$cmaximum :: forall boundaryPoint a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
maximum :: forall a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
$cminimum :: forall boundaryPoint a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
minimum :: forall a.
Ord a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
$csum :: forall boundaryPoint a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
sum :: forall a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
$cproduct :: forall boundaryPoint a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
product :: forall a.
Num a =>
Point_x_HalfSpace_Intersection boundaryPoint a -> a
Foldable,Functor (Point_x_HalfSpace_Intersection boundaryPoint)
Foldable (Point_x_HalfSpace_Intersection boundaryPoint)
(Functor (Point_x_HalfSpace_Intersection boundaryPoint),
Foldable (Point_x_HalfSpace_Intersection boundaryPoint)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> f (Point_x_HalfSpace_Intersection boundaryPoint b))
-> (forall (f :: * -> *) a.
Applicative f =>
Point_x_HalfSpace_Intersection boundaryPoint (f a)
-> f (Point_x_HalfSpace_Intersection boundaryPoint a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> m (Point_x_HalfSpace_Intersection boundaryPoint b))
-> (forall (m :: * -> *) a.
Monad m =>
Point_x_HalfSpace_Intersection boundaryPoint (m a)
-> m (Point_x_HalfSpace_Intersection boundaryPoint a))
-> Traversable (Point_x_HalfSpace_Intersection boundaryPoint)
forall boundaryPoint.
Functor (Point_x_HalfSpace_Intersection boundaryPoint)
forall boundaryPoint.
Foldable (Point_x_HalfSpace_Intersection boundaryPoint)
forall boundaryPoint (m :: * -> *) a.
Monad m =>
Point_x_HalfSpace_Intersection boundaryPoint (m a)
-> m (Point_x_HalfSpace_Intersection boundaryPoint a)
forall boundaryPoint (f :: * -> *) a.
Applicative f =>
Point_x_HalfSpace_Intersection boundaryPoint (f a)
-> f (Point_x_HalfSpace_Intersection boundaryPoint a)
forall boundaryPoint (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> m (Point_x_HalfSpace_Intersection boundaryPoint b)
forall boundaryPoint (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> f (Point_x_HalfSpace_Intersection boundaryPoint b)
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 =>
Point_x_HalfSpace_Intersection boundaryPoint (m a)
-> m (Point_x_HalfSpace_Intersection boundaryPoint a)
forall (f :: * -> *) a.
Applicative f =>
Point_x_HalfSpace_Intersection boundaryPoint (f a)
-> f (Point_x_HalfSpace_Intersection boundaryPoint a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> m (Point_x_HalfSpace_Intersection boundaryPoint b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> f (Point_x_HalfSpace_Intersection boundaryPoint b)
$ctraverse :: forall boundaryPoint (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> f (Point_x_HalfSpace_Intersection boundaryPoint b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> f (Point_x_HalfSpace_Intersection boundaryPoint b)
$csequenceA :: forall boundaryPoint (f :: * -> *) a.
Applicative f =>
Point_x_HalfSpace_Intersection boundaryPoint (f a)
-> f (Point_x_HalfSpace_Intersection boundaryPoint a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Point_x_HalfSpace_Intersection boundaryPoint (f a)
-> f (Point_x_HalfSpace_Intersection boundaryPoint a)
$cmapM :: forall boundaryPoint (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> m (Point_x_HalfSpace_Intersection boundaryPoint b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Point_x_HalfSpace_Intersection boundaryPoint a
-> m (Point_x_HalfSpace_Intersection boundaryPoint b)
$csequence :: forall boundaryPoint (m :: * -> *) a.
Monad m =>
Point_x_HalfSpace_Intersection boundaryPoint (m a)
-> m (Point_x_HalfSpace_Intersection boundaryPoint a)
sequence :: forall (m :: * -> *) a.
Monad m =>
Point_x_HalfSpace_Intersection boundaryPoint (m a)
-> m (Point_x_HalfSpace_Intersection boundaryPoint a)
Traversable)
instance Bifunctor Point_x_HalfSpace_Intersection where
bimap :: forall a b c d.
(a -> b)
-> (c -> d)
-> Point_x_HalfSpace_Intersection a c
-> Point_x_HalfSpace_Intersection b d
bimap a -> b
f c -> d
g = \case
Point_x_HalfSpace_OnBoundary a
p -> b -> Point_x_HalfSpace_Intersection b d
forall boundaryPoint interiorPoint.
boundaryPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_OnBoundary (a -> b
f a
p)
Point_x_HalfSpace_Interior c
p -> d -> Point_x_HalfSpace_Intersection b d
forall boundaryPoint interiorPoint.
interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_Interior (c -> d
g c
p)
instance Bifoldable Point_x_HalfSpace_Intersection where
bifoldMap :: forall m a b.
Monoid m =>
(a -> m) -> (b -> m) -> Point_x_HalfSpace_Intersection a b -> m
bifoldMap = (a -> m) -> (b -> m) -> Point_x_HalfSpace_Intersection a b -> m
forall m a b.
Semigroup m =>
(a -> m) -> (b -> m) -> Point_x_HalfSpace_Intersection a b -> m
forall (t :: * -> * -> *) m a b.
(Bifoldable1 t, Semigroup m) =>
(a -> m) -> (b -> m) -> t a b -> m
bifoldMap1
instance Bifoldable1 Point_x_HalfSpace_Intersection where
bifoldMap1 :: forall m a b.
Semigroup m =>
(a -> m) -> (b -> m) -> Point_x_HalfSpace_Intersection a b -> m
bifoldMap1 a -> m
f b -> m
g = \case
Point_x_HalfSpace_OnBoundary a
p -> a -> m
f a
p
Point_x_HalfSpace_Interior b
p -> b -> m
g b
p
instance Bitraversable Point_x_HalfSpace_Intersection where
bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c)
-> (b -> f d)
-> Point_x_HalfSpace_Intersection a b
-> f (Point_x_HalfSpace_Intersection c d)
bitraverse a -> f c
f b -> f d
g = \case
Point_x_HalfSpace_OnBoundary a
p -> c -> Point_x_HalfSpace_Intersection c d
forall boundaryPoint interiorPoint.
boundaryPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_OnBoundary (c -> Point_x_HalfSpace_Intersection c d)
-> f c -> f (Point_x_HalfSpace_Intersection c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
p
Point_x_HalfSpace_Interior b
p -> d -> Point_x_HalfSpace_Intersection c d
forall boundaryPoint interiorPoint.
interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_Interior (d -> Point_x_HalfSpace_Intersection c d)
-> f d -> f (Point_x_HalfSpace_Intersection c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> f d
g b
p
instance Bitraversable1 Point_x_HalfSpace_Intersection where
bitraverse1 :: forall (f :: * -> *) a b c d.
Apply f =>
(a -> f b)
-> (c -> f d)
-> Point_x_HalfSpace_Intersection a c
-> f (Point_x_HalfSpace_Intersection b d)
bitraverse1 a -> f b
f c -> f d
g = \case
Point_x_HalfSpace_OnBoundary a
p -> b -> Point_x_HalfSpace_Intersection b d
forall boundaryPoint interiorPoint.
boundaryPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_OnBoundary (b -> Point_x_HalfSpace_Intersection b d)
-> f b -> f (Point_x_HalfSpace_Intersection b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
p
Point_x_HalfSpace_Interior c
p -> d -> Point_x_HalfSpace_Intersection b d
forall boundaryPoint interiorPoint.
interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_Interior (d -> Point_x_HalfSpace_Intersection b d)
-> f d -> f (Point_x_HalfSpace_Intersection b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> c -> f d
g c
p
instance ( HyperPlane_ boudingHyperPlane d r, Ord r, Num r
, Has_ Additive_ d r
) => IsIntersectableWith (Point d r) (HalfSpaceF boudingHyperPlane) where
Point d r
q intersect :: Point d r
-> HalfSpaceF boudingHyperPlane
-> Intersection (Point d r) (HalfSpaceF boudingHyperPlane)
`intersect` (HalfSpace Sign
s boudingHyperPlane
h) = case Sign
s of
Sign
Positive -> case Point d r
q Point d r -> boudingHyperPlane -> Ordering
forall point.
(Point_ point d r, Ord r, Num r) =>
point -> boudingHyperPlane -> Ordering
forall hyperPlane (d :: Nat) r point.
(HyperPlane_ hyperPlane d r, Point_ point d r, Ord r, Num r) =>
point -> hyperPlane -> Ordering
`onSideTest` boudingHyperPlane
h of
Ordering
LT -> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
Intersection (Point d r) (HalfSpaceF boudingHyperPlane)
forall a. Maybe a
Nothing
Ordering
EQ -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a. a -> Maybe a
Just (Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r)))
-> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a b. (a -> b) -> a -> b
$ Point d r -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
forall boundaryPoint interiorPoint.
boundaryPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_OnBoundary Point d r
q
Ordering
GT -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a. a -> Maybe a
Just (Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r)))
-> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a b. (a -> b) -> a -> b
$ Point d r -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
forall boundaryPoint interiorPoint.
interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_Interior Point d r
q
Sign
Negative -> case Point d r
q Point d r -> boudingHyperPlane -> Ordering
forall point.
(Point_ point d r, Ord r, Num r) =>
point -> boudingHyperPlane -> Ordering
forall hyperPlane (d :: Nat) r point.
(HyperPlane_ hyperPlane d r, Point_ point d r, Ord r, Num r) =>
point -> hyperPlane -> Ordering
`onSideTest` boudingHyperPlane
h of
Ordering
LT -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a. a -> Maybe a
Just (Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r)))
-> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a b. (a -> b) -> a -> b
$ Point d r -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
forall boundaryPoint interiorPoint.
interiorPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_Interior Point d r
q
Ordering
EQ -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a. a -> Maybe a
Just (Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r)))
-> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
-> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
forall a b. (a -> b) -> a -> b
$ Point d r -> Point_x_HalfSpace_Intersection (Point d r) (Point d r)
forall boundaryPoint interiorPoint.
boundaryPoint
-> Point_x_HalfSpace_Intersection boundaryPoint interiorPoint
Point_x_HalfSpace_OnBoundary Point d r
q
Ordering
GT -> Maybe (Point_x_HalfSpace_Intersection (Point d r) (Point d r))
Intersection (Point d r) (HalfSpaceF boudingHyperPlane)
forall a. Maybe a
Nothing
instance ( HasSquaredEuclideanDistance boundingHyperPlane
, HasIntersectionWith (Point d r) (HalfSpaceF boundingHyperPlane)
, d ~ Dimension boundingHyperPlane, r ~ NumType boundingHyperPlane
)
=> HasSquaredEuclideanDistance (HalfSpaceF boundingHyperPlane) where
pointClosestTo :: forall r (d :: Nat) point.
(r ~ NumType (HalfSpaceF boundingHyperPlane),
d ~ Dimension (HalfSpaceF boundingHyperPlane), Num r,
Point_ point d r) =>
point -> HalfSpaceF boundingHyperPlane -> Point d r
pointClosestTo (Getting (Point d r) point (Point d r) -> point -> Point d r
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Point d r) point (Point d r)
forall point (d :: Nat) r.
Point_ point d r =>
Lens' point (Point d r)
Lens' point (Point d r)
asPoint -> Point d r
q) HalfSpaceF boundingHyperPlane
h
| Point d r
q Point d r -> HalfSpaceF boundingHyperPlane -> Bool
forall g h. HasIntersectionWith g h => g -> h -> Bool
`intersects` HalfSpaceF boundingHyperPlane
h = Point d r
q
| Bool
otherwise = Point d r -> boundingHyperPlane -> Point d r
forall g r (d :: Nat) point.
(HasSquaredEuclideanDistance g, r ~ NumType g, d ~ Dimension g,
Num r, Point_ point d r) =>
point -> g -> Point d r
forall r (d :: Nat) point.
(r ~ NumType boundingHyperPlane, d ~ Dimension boundingHyperPlane,
Num r, Point_ point d r) =>
point -> boundingHyperPlane -> Point d r
pointClosestTo Point d r
q (HalfSpaceF boundingHyperPlane
hHalfSpaceF boundingHyperPlane
-> Getting
boundingHyperPlane
(HalfSpaceF boundingHyperPlane)
boundingHyperPlane
-> boundingHyperPlane
forall s a. s -> Getting a s a -> a
^.Getting
boundingHyperPlane
(HalfSpaceF boundingHyperPlane)
boundingHyperPlane
(BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r
-> Const
boundingHyperPlane
(BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r))
-> HalfSpaceF boundingHyperPlane
-> Const boundingHyperPlane (HalfSpaceF boundingHyperPlane)
forall halfSpace (d :: Nat) r.
HalfSpace_ halfSpace d r =>
Lens' halfSpace (BoundingHyperPlane halfSpace d r)
Lens'
(HalfSpaceF boundingHyperPlane)
(BoundingHyperPlane (HalfSpaceF boundingHyperPlane) d r)
boundingHyperPlane)
instance ( HasIntersectionWith line line'
, HyperPlane_ line 2 r, HyperPlane_ line' 2 r
, Ord r, Fractional r
, HasPickInteriorPoint line 2 r, HasPickInteriorPoint line' 2 r
)
=> HasIntersectionWith (HalfSpaceF line) (HalfSpaceF line') where
h :: HalfSpaceF line
h@(HalfSpace Sign
_ line
l) intersects :: HalfSpaceF line -> HalfSpaceF line' -> Bool
`intersects` h' :: HalfSpaceF line'
h'@(HalfSpace Sign
_ line'
l') =
line
l line -> line' -> Bool
forall g h. HasIntersectionWith g h => g -> h -> Bool
`intersects` line'
l' Bool -> Bool -> Bool
|| line -> Point 2 r
forall geom (d :: Nat) r.
HasPickInteriorPoint geom d r =>
geom -> Point d r
pointInteriorTo line
l Point 2 r -> HalfSpaceF line' -> Bool
forall g h. HasIntersectionWith g h => g -> h -> Bool
`intersects` HalfSpaceF line'
h' Bool -> Bool -> Bool
|| line' -> Point 2 r
forall geom (d :: Nat) r.
HasPickInteriorPoint geom d r =>
geom -> Point d r
pointInteriorTo line'
l' Point 2 r -> HalfSpaceF line -> Bool
forall g h. HasIntersectionWith g h => g -> h -> Bool
`intersects` HalfSpaceF line
h
instance ( HasPickInteriorPoint hyperPlane d r
, HyperPlane_ hyperPlane d r
, 1 <= d, Eq r, Num r
, Has_ Additive_ d r
, Has_ Vector_ (1+d) r
) => HasPickInteriorPoint (HalfSpaceF hyperPlane) d r where
pointInteriorTo :: HalfSpaceF hyperPlane -> Point d r
pointInteriorTo HalfSpaceF hyperPlane
h = Point d r
p Point d r -> Vector d r -> Point d r
forall point (d :: Nat) r.
(Affine_ point d r, Num r) =>
point -> Vector d r -> point
.+^ Vector d r -> Vector d r
f (hyperPlane -> Vector d r
forall hyperPlane (d :: Nat) r.
(HyperPlane_ hyperPlane d r, Num r, Eq r, 1 <= d) =>
hyperPlane -> Vector d r
normalVector hyperPlane
l)
where
l :: hyperPlane
l = HalfSpaceF hyperPlane
hHalfSpaceF hyperPlane
-> Getting hyperPlane (HalfSpaceF hyperPlane) hyperPlane
-> hyperPlane
forall s a. s -> Getting a s a -> a
^.Getting hyperPlane (HalfSpaceF hyperPlane) hyperPlane
(BoundingHyperPlane (HalfSpaceF hyperPlane) d r
-> Const
hyperPlane (BoundingHyperPlane (HalfSpaceF hyperPlane) d r))
-> HalfSpaceF hyperPlane
-> Const hyperPlane (HalfSpaceF hyperPlane)
forall halfSpace (d :: Nat) r.
HalfSpace_ halfSpace d r =>
Lens' halfSpace (BoundingHyperPlane halfSpace d r)
Lens'
(HalfSpaceF hyperPlane)
(BoundingHyperPlane (HalfSpaceF hyperPlane) d r)
boundingHyperPlane
p :: Point d r
p = hyperPlane -> Point d r
forall geom (d :: Nat) r.
HasPickInteriorPoint geom d r =>
geom -> Point d r
pointInteriorTo hyperPlane
l
f :: Vector d r -> Vector d r
f = case HalfSpaceF hyperPlane
hHalfSpaceF hyperPlane
-> Getting Sign (HalfSpaceF hyperPlane) Sign -> Sign
forall s a. s -> Getting a s a -> a
^.Getting Sign (HalfSpaceF hyperPlane) Sign
forall halfSpace (d :: Nat) r.
HalfSpace_ halfSpace d r =>
Lens' halfSpace Sign
Lens' (HalfSpaceF hyperPlane) Sign
halfSpaceSign of
Sign
Positive -> Vector d r -> Vector d r
forall a. a -> a
id
Sign
Negative -> Vector d r -> Vector d r
forall r vector (d :: Nat).
(Num r, Vector_ vector d r) =>
vector -> vector
negated