Skip to content

Commit

Permalink
Add examples for triangulate and urquhart
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed Mar 3, 2024
1 parent fbb8c46 commit 3226695
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
17 changes: 17 additions & 0 deletions README.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 31 additions & 7 deletions README.md.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions examples/urquhart/generate.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes
File renamed without changes

0 comments on commit 3226695

Please sign in to comment.