Skip to content

Instantly share code, notes, and snippets.

@joe-warren
Created January 30, 2024 03:07
Show Gist options
  • Save joe-warren/f4624dccea0489cce4270a292d6b5a0b to your computer and use it in GitHub Desktop.
Save joe-warren/f4624dccea0489cce4270a292d6b5a0b to your computer and use it in GitHub Desktop.
import qualified Waterfall
import Linear
import Algebra.Lattice
import Algebra.Lattice.Dropped
intersection :: (Functor f, Foldable f) => f Waterfall.Solid -> Waterfall.Solid
intersection = foldDropped Waterfall.nowhere id . meets . fmap Drop
cubes :: Waterfall.Solid
cubes =
let phi = (1 + sqrt 5) / 2
axis = V3 1 phi 0
angle = 2 * pi / 5
in mconcat . take 5 . iterate (Waterfall.rotate axis angle) $ Waterfall.centeredCube
mask :: Waterfall.Solid
mask = Waterfall.uScale 100 . Waterfall.translate (0.5 *^ unit _z) $ Waterfall.centeredCube
slot :: Waterfall.Solid
slot = Waterfall.rotate (unit _x) (pi/2) . Waterfall.scale (V3 (26/2) (26/2) 2.5) $ Waterfall.centeredCylinder
main :: IO ()
main = do
let stlRes = 0.1
Waterfall.writeSTL stlRes "cubes.stl" cubes
Waterfall.writeSTL stlRes "cubes-a.stl" (((Waterfall.uScale 50 cubes) `Waterfall.intersection` mask ) `Waterfall.difference` slot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment