Skip to content

georust/earcut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

earcut-rs

CI codecov Crates.io Version

A Rust port of the mapbox/earcut polygon triangulation library.

  • Based on the latest earcut 3.0.2 release.
  • Designed to avoid unnecessary memory allocations. Internal buffers and the output index vector can be reused across multiple triangulations.
  • Also provides earcut::int::EarcutI32 for integer coordinates with exact integer predicates, but it can be slower than the float-based Earcut on modern CPUs.
  • An additional module, utils3d, can project 3D coplanar polygons onto a 2D plane before triangulation.

Benchmarks

Measured on a MacBook Pro (M1 Pro).

Polygon earcut.hpp earcut-rs (0.4.9) earcutr (0.4.3)
bad_hole 3.55 µs/i 2.650 µs/i 4.415 µs/i
building 351 ns/i 155 ns/i 604 ns/i
degenerate 154 ns/i 39 ns/i 206 ns/i
dude 5.25 µs/i 4.535 µs/i 8.096 µs/i
empty_square 202 ns/i 66 ns/i 331 ns/i
water 423 µs/i 400.9 µs/i 801.3 µs/i
water2 338 µs/i 291.4 µs/i 450.3 µs/i
water3 13.6 µs/i 13.03 µs/i 23.46 µs/i
water3b 1.28 µs/i 1.057 µs/i 2.165 µs/i
water4 89.1 µs/i 74.78 µs/i 154.1 µs/i
water_huge 7.240 ms/i 7.456 ms/i 10.90 ms/i
water_huge2 15.86 ms/i 16.26 ms/i 22.35 ms/i

Note: earcut.hpp and earcutr have not fully caught up with the latest mapbox/earcut.

License

Licensed under either the MIT License (LICENSE-MIT) or the Apache License 2.0 (LICENSE-APACHE) at your option.

This project contains portions derived from mapbox/earcut, originally distributed under the ISC License (LICENSE-ISC).

About

A Rust port of the Earcut polygon triangulation library

Topics

Resources

License

Apache-2.0 and 2 other licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
ISC
LICENSE-ISC
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Contributors

Languages