Skip to content

Instantly share code, notes, and snippets.

@joe-warren
Last active October 13, 2025 16:30
Show Gist options
  • Select an option

  • Save joe-warren/d3b4db57b01f8bb51636761925df5e51 to your computer and use it in GitHub Desktop.

Select an option

Save joe-warren/d3b4db57b01f8bb51636761925df5e51 to your computer and use it in GitHub Desktop.
#!/usr/bin/env stack
{- stack script --resolver lts-23.15
--package linear
--package waterfall-cad
--extra-dep waterfall-cad-0.6.0.0
--extra-dep opencascade-hs-0.6.0.0
-}
import Linear
import qualified Waterfall as W
keyAdaptor :: W.Solid
keyAdaptor =
let
tolerance = 0.5
xSection = W.uScale2D 8.5 $ W.unitPolygon 6
r = (9.3 + tolerance)/2
centerHole = W.scale (V3 r r (6.2 + tolerance)) $ W.unitCylinder
nutR = (3.6 + tolerance)/2
nutH = 0.9 + nutR
nutHole = W.translate (nutH *^ unit _z). W.rotate (unit _x) (pi/2) . W.scale (V3 nutR nutR 10) $ W.unitCylinder
in W.prism 35 xSection `W.difference` (centerHole <> nutHole)
main :: IO ()
main = W.writeSTL 0.01 "key_adaptor.stl" keyAdaptor
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment