Expand description
§earclip
§Description
The earclip module is a tool to convert 2D and 3D polygons into a triangle mesh designed to be
fast, efficient, and sphere capable.
§Install
cargo add earclip§Usage
This crate takes advantage of the s2json::GetXY and s2json::GetZ traits for 2D and 3D
polygon triangulation. If you need to use your own 2D and 3D polygon types, just implement
those traits for them.
crate::earclip: for 2D and 3D polygon triangulationcrate::earclip_float: for 2D and 3D polygon triangulation on flattened f64 datacrate::tesselate: for tesselating a flattened polygoncrate::flatten: for flattening a 2D or 3D polygoncrate::flatten_float: for flattening a 2D or 3D polygon whose points are f64 vectors
§Example
use earclip::earclip_float;
let polygon = vec![vec![vec![0.0, 0.0, 0.0], vec![1.0, 0.0, 0.0], vec![0.0, 1.0, 0.0]]];
let (vertices, indices) = earclip_float(&polygon, None, None);
assert_eq!(vertices, vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]);
assert_eq!(indices, vec![1, 2, 0]);Re-exports§
pub use earcut::earcut;pub use earcut::signed_area;
Modules§
- earcut
- The
earcutmodule
Traits§
Functions§
- deviation
- Returns a percentage difference between the polygon area and its triangulation area; used to verify correctness of triangulation
- earclip
- An earcut polygon generator with tesselation support
- earclip_
float - An earcut polygon generator with tesselation support
- flatten
- Flattens a 2D or 3D array whether its a flat point ([x, y, z]) or object ({ x, y, z })
- flatten_
float - Flattens a 2D or 3D array whether its a flat point ([x, y, z]) or object ({ x, y, z })
- tesselate
- Tesselates the flattened polygon