From 3226695d11b5ad3797da2c211d53141a06e92b54 Mon Sep 17 00:00:00 2001 From: Austin Gill Date: Sun, 3 Mar 2024 11:51:18 -0600 Subject: [PATCH] Add examples for triangulate and urquhart --- README.md.in | 17 +++++++++ README.md.out | 38 +++++++++++++++---- examples/urquhart/generate.sh | 30 +++++++++++++++ .../triangulation.svg} | 0 examples/{ => urquhart}/urquhart.svg | 0 5 files changed, 78 insertions(+), 7 deletions(-) create mode 100755 examples/urquhart/generate.sh rename examples/{delaunay.svg => urquhart/triangulation.svg} (100%) rename examples/{ => urquhart}/urquhart.svg (100%) diff --git a/README.md.in b/README.md.in index 89bb7a9..45f439a 100644 --- a/README.md.in +++ b/README.md.in @@ -301,7 +301,24 @@ $ @TRAVERSE_SNIPPET@ ![](examples/traverse/hex-walk.svg) ### triangulate +The `triangulate` tool finds the Delaunay triangulation of the given geometries. It can triangulate +individual geometries, or relax all geometries into a point cloud, and triangulate the point cloud. + +```sh +$ @TRIANGULATE_SNIPPET@ +``` +![](examples/urquhart/triangulation.svg) + ### urquhart +The [Urquhart Graph](https://en.wikipedia.org/wiki/Urquhart_graph) is a computationally easy(ish) +approximation to the [Relative Neighborhood +Graph](https://en.wikipedia.org/wiki/Relative_neighborhood_graph). It's formed from the Delaunay +triangulation. + +```sh +@URQUHART_SNIPPET@ +``` +![](examples/urquhart/urquhart.svg) ## Transformations ### project.py diff --git a/README.md.out b/README.md.out index 62339d8..e139788 100644 --- a/README.md.out +++ b/README.md.out @@ -296,18 +296,42 @@ $ @STREAMLINE_SNIPPET2@ ### traverse The `traverse` tool performs random walks on the given graph. ```sh -$ grid --grid-type hexagon --output-format graph | - traverse \ - --seed=10268415722561053759 \ - --traversals 2 \ - --length 20 \ - --untraversed | - wkt2svg --scale 100 --output ./examples/traverse/hex-walk.svg +$ @TRAVERSE_SNIPPET@ ``` ![](examples/traverse/hex-walk.svg) ### triangulate +The `triangulate` tool finds the Delaunay triangulation of the given geometries. It can triangulate +individual geometries, or relax all geometries into a point cloud, and triangulate the point cloud. + +```sh +$ # Save the points for later +point-cloud --seed 11878883030565683752 --points 20 --scale 200 | + triangulate | sort | tee /tmp/triangulation.wkt | + wkt2svg --output ./examples/urquhart/triangulation.svg +``` +![](examples/urquhart/triangulation.svg) + ### urquhart +The [Urquhart Graph](https://en.wikipedia.org/wiki/Urquhart_graph) is a computationally easy(ish) +approximation to the [Relative Neighborhood +Graph](https://en.wikipedia.org/wiki/Relative_neighborhood_graph). It's formed from the Delaunay +triangulation. + +```sh +point-cloud --seed 11878883030565683752 --points 20 --scale 200 | + urquhart | sort >/tmp/urquhart.wkt +{ + echo "STROKE(gray)" + echo "STROKEDASHARRAY(6)" + # the triangulation minus the urquhart graph + comm -23 /tmp/triangulation.wkt /tmp/urquhart.wkt + echo "STROKE(black)" + echo "STROKEDASHARRAY(none)" + cat /tmp/urquhart.wkt +} | wkt2svg --output ./examples/urquhart/urquhart.svg +``` +![](examples/urquhart/urquhart.svg) ## Transformations ### project.py diff --git a/examples/urquhart/generate.sh b/examples/urquhart/generate.sh new file mode 100755 index 0000000..a2c15e3 --- /dev/null +++ b/examples/urquhart/generate.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o nounset +# We _want_ to clobber any existing stash files in /tmp +set +o noclobber + +# BEGIN TRIANGULATE_SNIPPET +point-cloud --seed 11878883030565683752 --points 20 --scale 200 | + triangulate | sort | tee /tmp/triangulation.wkt | + wkt2svg --output ./examples/urquhart/triangulation.svg +# END TRIANGULATE_SNIPPET +extract_snippet TRIANGULATE_SNIPPET + +# BEGIN URQUHART_SNIPPET +point-cloud --seed 11878883030565683752 --points 20 --scale 200 | + urquhart | sort >/tmp/urquhart.wkt +{ + echo "STROKE(gray)" + echo "STROKEDASHARRAY(6)" + # the triangulation minus the urquhart graph + comm -23 /tmp/triangulation.wkt /tmp/urquhart.wkt + echo "STROKE(black)" + echo "STROKEDASHARRAY(none)" + cat /tmp/urquhart.wkt +} | wkt2svg --output ./examples/urquhart/urquhart.svg +# END URQUHART_SNIPPET +extract_snippet URQUHART_SNIPPET + +set -o noclobber diff --git a/examples/delaunay.svg b/examples/urquhart/triangulation.svg similarity index 100% rename from examples/delaunay.svg rename to examples/urquhart/triangulation.svg diff --git a/examples/urquhart.svg b/examples/urquhart/urquhart.svg similarity index 100% rename from examples/urquhart.svg rename to examples/urquhart/urquhart.svg