Files
loop/src/Bound.hs
T
2022-08-21 21:53:40 +01:00

23 lines
543 B
Haskell

module Bound (
boundPoints,
) where
import qualified Control.Foldl as L
import Control.Lens
import Geometry
---- NSEW
boundPoints :: [Point2] -> Maybe (Float, Float, Float, Float)
{-# INLINE boundPoints #-}
boundPoints =
f
. L.fold
( (,,,)
<$> L.premap (^?! _2) L.maximum
<*> L.premap (^?! _2) L.minimum
<*> L.premap (^?! _1) L.maximum
<*> L.premap (^?! _1) L.minimum
)
where
f (mn, ms, me, mw) = (,,,) <$> mn <*> ms <*> me <*> mw