diff --git a/snub-dodecahedron/README.md b/snub-dodecahedron/README.md index f4e9667..edde09a 100644 --- a/snub-dodecahedron/README.md +++ b/snub-dodecahedron/README.md @@ -65,26 +65,33 @@ coplanar and glue flush at the correct angle. ## Requirements +This project is run with [uv](https://docs.astral.sh/uv/). The Python scripts +carry [inline dependency metadata (PEP 723)](https://docs.astral.sh/uv/guides/scripts/), +so `uv run` automatically creates an isolated environment with `numpy`/`scipy` +on first use — there is nothing to install manually. + ```bash -pip install numpy scipy # geometry + convex hull +# install uv (see https://docs.astral.sh/uv/getting-started/installation/) +curl -LsSf https://astral.sh/uv/install.sh | sh # or: pip install uv + # OpenSCAD is only needed to render STLs (the .scad is written regardless) -sudo apt-get install openscad # or download from https://openscad.org +sudo apt-get install openscad # or https://openscad.org ``` ## Usage ```bash # default: 30 mm edges, 3 mm thick, single net, writes out/snub_net.scad + preview -python3 generate.py +uv run generate.py # pick your own size/depth and also render an STL -python3 generate.py --edge 35 --depth 4 --web 0.6 --slack 6 --stl +uv run generate.py --edge 35 --depth 4 --web 0.6 --slack 6 --stl # split into smaller pieces (≤ 20 faces each) for easier printing/handling -python3 generate.py --max-faces-per-piece 20 --stl +uv run generate.py --max-faces-per-piece 20 --stl # also export the target solid as a reference model -python3 generate.py --solid +uv run generate.py --solid ``` Open the generated `.scad` in OpenSCAD (or use `--stl`) to get a mesh, then @@ -140,6 +147,6 @@ angles matching the known 164.175° / 152.930°. The unfolder additionally runs an independent SAT overlap check to confirm no two faces overlap in the layout. ```bash -python3 snubgeom.py # prints the verified geometry stats -python3 preview.py # writes net_preview.svg, reports overlapping pairs (0) +uv run snubgeom.py # prints the verified geometry stats +uv run preview.py # writes net_preview.svg, reports overlapping pairs (0) ``` diff --git a/snub-dodecahedron/generate.py b/snub-dodecahedron/generate.py index 4814a65..0bdf239 100644 --- a/snub-dodecahedron/generate.py +++ b/snub-dodecahedron/generate.py @@ -1,9 +1,13 @@ #!/usr/bin/env python3 +# /// script +# requires-python = ">=3.9" +# dependencies = ["numpy>=1.24", "scipy>=1.10"] +# /// """ Generate a foldable, beveled snub-dodecahedron net as OpenSCAD (+ optional STL). Example: - python3 generate.py --edge 30 --depth 3 --web 0.6 --slack 6 --stl + uv run generate.py --edge 30 --depth 3 --web 0.6 --slack 6 --stl The output is a flat plate you print, then fold along the grooved hinges and glue the seams to obtain a snub dodecahedron. See README.md for details. diff --git a/snub-dodecahedron/preview.py b/snub-dodecahedron/preview.py index 2cb15ea..08e7e6f 100644 --- a/snub-dodecahedron/preview.py +++ b/snub-dodecahedron/preview.py @@ -1,3 +1,7 @@ +# /// script +# requires-python = ">=3.9" +# dependencies = ["numpy>=1.24", "scipy>=1.10"] +# /// """Render an SVG preview of the unfolded net(s) and verify no faces overlap.""" from __future__ import annotations diff --git a/snub-dodecahedron/requirements.txt b/snub-dodecahedron/requirements.txt deleted file mode 100644 index 0ffddef..0000000 --- a/snub-dodecahedron/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -numpy>=1.24 -scipy>=1.10 diff --git a/snub-dodecahedron/snubgeom.py b/snub-dodecahedron/snubgeom.py index 801f94f..a1b92b2 100644 --- a/snub-dodecahedron/snubgeom.py +++ b/snub-dodecahedron/snubgeom.py @@ -1,3 +1,7 @@ +# /// script +# requires-python = ">=3.9" +# dependencies = ["numpy>=1.24", "scipy>=1.10"] +# /// """ Exact geometry of the snub dodecahedron (an Archimedean solid). diff --git a/snub-dodecahedron/unfold.py b/snub-dodecahedron/unfold.py index 8ed90f2..9f856a6 100644 --- a/snub-dodecahedron/unfold.py +++ b/snub-dodecahedron/unfold.py @@ -1,3 +1,7 @@ +# /// script +# requires-python = ">=3.9" +# dependencies = ["numpy>=1.24", "scipy>=1.10"] +# /// """ Unfold the snub dodecahedron into one or more flat, non-overlapping nets.