module BoundingBoxExample
(boundingBoxExample
) where

import Data.Function ((&))
import qualified Waterfall.Solids as Solids
import qualified Waterfall.BoundingBox.Oriented as OBB
import qualified Waterfall.BoundingBox.AxisAligned as AABB
import qualified Waterfall.Transforms as Transforms
import Linear (V3 (..), unit, _y, _z, (^*))

boundingBoxExample :: Solids.Solid
boundingBoxExample :: Solid
boundingBoxExample = 
    let shape :: Solid
shape = Solid
Solids.unitSphere Solid -> (Solid -> Solid) -> Solid
forall a b. a -> (a -> b) -> b
&
            V3 Double -> Solid -> Solid
forall a. Transformable a => V3 Double -> a -> a
Transforms.scale (Double -> Double -> Double -> V3 Double
forall a. a -> a -> a -> V3 a
V3 Double
0.5 Double
3 Double
5) Solid -> (Solid -> Solid) -> Solid
forall a b. a -> (a -> b) -> b
&
            V3 Double -> Double -> Solid -> Solid
forall a. Transformable a => V3 Double -> Double -> a -> a
Transforms.rotate (ASetter' (V3 Double) Double -> V3 Double
forall (t :: * -> *) a.
(Additive t, Num a) =>
ASetter' (t a) a -> t a
unit ASetter' (V3 Double) Double
forall a. Lens' (V3 a) a
forall (t :: * -> *) a. R3 t => Lens' (t a) a
_z) Double
1 Solid -> (Solid -> Solid) -> Solid
forall a b. a -> (a -> b) -> b
&
            V3 Double -> Double -> Solid -> Solid
forall a. Transformable a => V3 Double -> Double -> a -> a
Transforms.rotate (ASetter' (V3 Double) Double -> V3 Double
forall (t :: * -> *) a.
(Additive t, Num a) =>
ASetter' (t a) a -> t a
unit ASetter' (V3 Double) Double
forall a. Lens' (V3 a) a
forall (t :: * -> *) a. R2 t => Lens' (t a) a
_y) Double
0.5
        obb :: Solid
obb = Solid -> Maybe OrientedBoundingBox
OBB.orientedBoundingBox Solid
shape Maybe OrientedBoundingBox
-> (Maybe OrientedBoundingBox -> Solid) -> Solid
forall a b. a -> (a -> b) -> b
&
            Solid
-> (OrientedBoundingBox -> Solid)
-> Maybe OrientedBoundingBox
-> Solid
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Solid
Solids.nowhere OrientedBoundingBox -> Solid
OBB.obbToSolid
        aabb :: Solid
aabb = Solid -> Maybe (V3 Double, V3 Double)
AABB.axisAlignedBoundingBox Solid
shape Maybe (V3 Double, V3 Double)
-> (Maybe (V3 Double, V3 Double) -> Solid) -> Solid
forall a b. a -> (a -> b) -> b
&
            Solid
-> ((V3 Double, V3 Double) -> Solid)
-> Maybe (V3 Double, V3 Double)
-> Solid
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Solid
Solids.nowhere (V3 Double, V3 Double) -> Solid
AABB.aabbToSolid
        in [Solid] -> Solid
forall a. Monoid a => [a] -> a
mconcat 
            [ V3 Double -> Solid -> Solid
forall a. Transformable a => V3 Double -> a -> a
Transforms.translate (ASetter' (V3 Double) Double -> V3 Double
forall (t :: * -> *) a.
(Additive t, Num a) =>
ASetter' (t a) a -> t a
unit ASetter' (V3 Double) Double
forall a. Lens' (V3 a) a
forall (t :: * -> *) a. R2 t => Lens' (t a) a
_y V3 Double -> Double -> V3 Double
forall (f :: * -> *) a. (Functor f, Num a) => f a -> a -> f a
^* (-Double
5)) Solid
shape
            , Solid
obb
            , V3 Double -> Solid -> Solid
forall a. Transformable a => V3 Double -> a -> a
Transforms.translate (ASetter' (V3 Double) Double -> V3 Double
forall (t :: * -> *) a.
(Additive t, Num a) =>
ASetter' (t a) a -> t a
unit ASetter' (V3 Double) Double
forall a. Lens' (V3 a) a
forall (t :: * -> *) a. R2 t => Lens' (t a) a
_y V3 Double -> Double -> V3 Double
forall (f :: * -> *) a. (Functor f, Num a) => f a -> a -> f a
^* Double
5) Solid
aabb
            ]