https://github.com/intendednull/clipping
https://github.com/intendednull/clipping
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/intendednull/clipping
- Owner: intendednull
- License: gpl-3.0
- Created: 2021-08-23T03:01:43.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-23T03:26:03.000Z (almost 5 years ago)
- Last Synced: 2025-02-11T22:03:00.165Z (over 1 year ago)
- Language: Rust
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Clipping
Efficient clipping of arbitrary polygons using the Greiner-Hormann algorithm.
This implementation is based on this one :
# Usage
Cargo.toml :
```
clipping = "0.1.0"
```
main.rs :
```
extern crate clipping;
use clipping::CPolygon;
fn main() {
// two polygons
let poly_a: Vec<[f64; 2]> = vec![[40., 34.], [200., 66.], [106., 80.], [120., 175.]];
let poly_b = vec![[133., 120.], [80., 146.], [26., 106.], [40., 90.], [0., 53.], [80., 66.], [146., 0.]];
// Get the clipping polygons
let mut cp_a = CPolygon::from_vec(&poly_a);
let mut cp_b = CPolygon::from_vec(&poly_b);
// clip operation (intersection, union, difference)
let cp_ab = cp_a.intersection(&mut cp_b);
// handle the new polygons
for poly_c in cp_ab{
println!("Cliped polygon : {:?}", poly_c);
}
}
```