module Geometry.Plane
  ( Plane(..)
  , xyBack
  , xyFront
  , xzUp
  , xzDown
  , yzLeft
  , yzRight
  ) where

import RIO

import Geomancy (Vec3, vec3)

data Plane = Plane
  { Plane -> Vec3
normal :: Vec3
  , Plane -> Float
depth  :: Float
  }
  deriving (Int -> Plane -> ShowS
[Plane] -> ShowS
Plane -> String
(Int -> Plane -> ShowS)
-> (Plane -> String) -> ([Plane] -> ShowS) -> Show Plane
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Plane] -> ShowS
$cshowList :: [Plane] -> ShowS
show :: Plane -> String
$cshow :: Plane -> String
showsPrec :: Int -> Plane -> ShowS
$cshowsPrec :: Int -> Plane -> ShowS
Show)

-- | XY plane facing back.
xyBack :: Float -> Plane
xyBack :: Float -> Plane
xyBack Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 Float
0 Float
0 (-Float
1)
  , $sel:depth:Plane :: Float
depth  = Float
d
  }

-- | XY plane facing front.
xyFront :: Float -> Plane
xyFront :: Float -> Plane
xyFront Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 Float
0 Float
0 Float
1
  , $sel:depth:Plane :: Float
depth  = Float
d
  }

-- | XZ plane facing up.
xzUp :: Float -> Plane
xzUp :: Float -> Plane
xzUp Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 Float
0 (-Float
1) Float
0
  , $sel:depth:Plane :: Float
depth  = Float
d
  }

-- | XZ plane facing down.
xzDown :: Float -> Plane
xzDown :: Float -> Plane
xzDown Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 Float
0 Float
1 Float
0
  , $sel:depth:Plane :: Float
depth  = Float
d
  }

-- | YZ plane facing left.
yzLeft :: Float -> Plane
yzLeft :: Float -> Plane
yzLeft Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 (-Float
1) Float
0 Float
0
  , $sel:depth:Plane :: Float
depth  = Float
d
  }

-- | YZ plane facing right.
yzRight :: Float -> Plane
yzRight :: Float -> Plane
yzRight Float
d = Plane :: Vec3 -> Float -> Plane
Plane
  { $sel:normal:Plane :: Vec3
normal = Float -> Float -> Float -> Vec3
vec3 Float
1 Float
0 Float
0
  , $sel:depth:Plane :: Float
depth  = Float
d
  }