Efficient clipping of arbitrary polygons using the Greiner-Hormann algorithm. This implementation is based on this one : https://github.com/helderco/univ-polyclip
Cargo.toml :
clipping = "0.1.0"
main.rs : ``` extern crate clipping;
use clipping::CPolygon;
fn main() { // two polygons let polya: Vec<[f64; 2]> = vec![[40., 34.], [200., 66.], [106., 80.], [120., 175.]]; let polyb = vec![[133., 120.], [80., 146.], [26., 106.], [40., 90.], [0., 53.], [80., 66.], [146., 0.]];
// Get the clipping polygons let mut cpa = CPolygon::fromvec(&polya); let mut cpb = CPolygon::fromvec(&polyb);
// clip operation (intersection, union, difference) let cpab = cpa.intersection(&mut cp_b);
// handle the new polygons for polyc in cpab{ println!("Cliped polygon : {:?}", poly_c); } } ```