ImplicitCAD/Examples/example17.hs

26 lines
941 B
Haskell
Raw Normal View History

2019-06-06 09:58:14 +03:00
-- Example 17, pulled from our benchmarking suite.
import Control.Applicative (pure)
import Prelude ((<$>), ($), zipWith3, fmap, fromIntegral, (*), (/), Bool(..))
import Graphics.Implicit (cube, union, translate, writeSTL, V3(..))
2019-12-31 17:26:37 +03:00
import Graphics.Implicit.Definitions (Fast, , 3, SymbolicObj3)
2019-06-06 09:58:14 +03:00
default (Fast, )
object2 :: SymbolicObj3
object2 = squarePipe (pure 10) 1 100
2019-06-06 09:58:14 +03:00
where
2019-12-31 17:26:37 +03:00
squarePipe :: 3 -> -> -> SymbolicObj3
squarePipe (V3 x y z) diameter precision =
2019-06-06 09:58:14 +03:00
union
((\start -> translate start
$ cube True (pure diameter)
2019-12-31 20:18:25 +03:00
)
<$>
zipWith3
V3
(fmap (\n -> (fromIntegral n / precision) * x) [0..100])
(fmap (\n -> (fromIntegral n / precision) * y) [0..100])
(fmap (\n -> (fromIntegral n / precision) * z) [0..100]))
2019-06-06 09:58:14 +03:00
main = writeSTL 1 "example17.stl" object2