### 7 releases

Uses old Rust 2015

0.3.1 | May 23, 2018 |
---|---|

0.3.0 | May 23, 2018 |

0.2.1 | Jan 22, 2017 |

0.1.2 | Jan 17, 2017 |

#**874** in Algorithms

**88** downloads per month

**MIT**license

22KB

362 lines

# rtriangulate

A Rust implementation of the Delaunay triangulation algorithm presented by Paul Bourke.

Find the crate documentation on docs.rs, or here on Github.

This was developed as an exercise to get more used to Rust. As far as I know, it works, but it
might not. Also, this is a O(n^{1.5}) (approximatively) algorithm, it's not parallelized,
and it doesn't use the GPU at all.

## Usage

Add the rtriangulate dependency to

:`Cargo .toml`

`[``dependencies``]`
`rtriangulate ``=` `"`0.3`"`

And use the crate as such:

`extern` `crate` rtriangulate`;`
`use` `rtriangulate``::``{`TriangulationPoint`,` triangulate`}``;`
`fn` `main``(``)`` ``{`
`//` A list of points (which has to be sorted on x).
`//` Note that you can use your own point type, just implement the rtriangulate::Point trait.
`let` points `=` `[`
`TriangulationPoint``::`new`(``10.``0``,` `50.``0``)``,`
`TriangulationPoint``::`new`(``25.``0``,` `40.``0``)``,`
`TriangulationPoint``::`new`(``30.``0``,` `40.``0``)`
`]``;`
`//` In case you need to sort your points:
`//` points.sort_unstable_by(rtriangulate::sort_points);
`//` Do the triangulation.
`let` triangles `=` `triangulate``(``&`points`)``.``unwrap``(``)``;`
`println!``(``"``{:?}``"``,` triangles`)``;` `//` [Triangle(1, 0, 2)]
`}`

## License

MIT - See

file.`LICENSE`

#### Dependencies

~155KB