### 1 unstable release

0.1.0 | Jun 25, 2021 |
---|

#**2022** in Algorithms

**746** downloads per month

Used in **4** crates
(2 directly)

**MIT/Apache**

105KB

1.5K
SLoC

`cdt`

`cdt`

is a library for calculating
Delaunay and
constrained Delaunay
triangulations.`cdt`

It is optimized for correctness and speed, using exact predicates to perform point-in-circle and orientation tests.

###
`lib.rs`

:

is a library for calculating
Delaunay and
constrained Delaunay
triangulations.`cdt`

It is optimized for correctness and speed, using exact predicates to perform point-in-circle and orientation tests.

# Examples

## Delaunay triangulation

This triangulates a set of four points in a square

`let` pts `=` `vec!``[``(``0.``0``,` `0.``0``)``,` `(``1.``0``,` `0.``0``)``,` `(``1.``0``,` `1.``0``)``,` `(``0.``0``,` `1.``0``)``]``;`
`let` triangles `=` `cdt``::`triangulate_points`(``&`pts`)``.``unwrap``(``)``;`
`assert!``(`triangles`.``len``(``)` `==` `2``)``;`
`for` t `in` triangles `{`
`println!``(``"``{:?}` `{:?}` `{:?}``"``,` pts`[`t`.``0``]``,` pts`[`t`.``1``]``,` pts`[`t`.``2``]``)`
`}`

## Constrained Delaunay triangulation

This triangulates an inner and outer square

`let` pts `=` `vec!``[``(``0.``0``,` `0.``0``)``,` `(``1.``0``,` `0.``0``)``,` `(``1.``0``,` `1.``0``)``,` `(``0.``0``,` `1.``0``)``,`
`(``0.``2``,` `0.``2``)``,` `(``0.``8``,` `0.``2``)``,` `(``0.``8``,` `0.``8``)``,` `(``0.``2``,` `0.``8``)``]``;`
`let` triangles `=` `cdt``::`triangulate_contours`(``&`pts`,`
`&``[``vec!``[``0``,` `1``,` `2``,` `3``,` `0``]``,` `vec!``[``4``,` `5``,` `6``,` `7``,` `4``]``]``)`
`.``unwrap``(``)``;`
`for` t `in` triangles `{`
`println!``(``"``{:?}` `{:?}` `{:?}``"``,` pts`[`t`.``0``]``,` pts`[`t`.``1``]``,` pts`[`t`.``2``]``)`
`}`

# Crate features

By default, the library uses

indexes for internal data structures,
to improve performance. If you are planning to triangulate more than 500M
points in a single pass, you should enable the `u32`

feature.`long-indexes`

#### Dependencies

~1.1–1.6MB

~38K SLoC