[Haskell-cafe] ANN: mecha-0.0.1
tomahawkins at gmail.com
Sat Oct 31 19:27:25 EDT 2009
Mecha is a little solid modeling language intended for machine design.
Mecha has two layers: a pure functional layer for defining solids
(aka. parts), and a monadic layer for arranging parts into assemblies.
Solids (parts) are built using set operations on solid primitives. A
solid primitives is simply a predicate that says whether a point in
space is inside the solid:
data Solid = Solid (Vector -> Bool)
Mesh generation is performed by adaptive marching cubes.
It's slow, especially if you don't have graphics hardware. And solids
with hard edges don't render very clean. But the basics work.
Here's a simple example:
example :: IO ()
example = view design
design :: Asm ()
design = do
a <- part 1 0.06 8 $ difference sphereCube cyl3
b <- part 1 0.08 8 $ sphereCube
c <- part 1.5 0.08 8 $ cyl3
color (0, 0, 0.8) $ place a
move (-4, 0, 0) $ color (0.8, 0, 0) $ place b
move ( 0, 4, 0) $ color (0, 0.8, 0) $ place c
sphereCube = intersection sphere $ scaleXYZ 0.75 cube
cyl = scale (0.5, 0.5, 1.2) $ cylinder
cyl3 = unions [cyl, rotateX (pi / 2) cyl, rotateY (pi / 2) cyl]
More information about the Haskell-Cafe