Crates.io | offset-polygon |
lib.rs | offset-polygon |
version | 0.1.0 |
source | src |
created_at | 2019-07-03 00:12:24.061258 |
updated_at | 2019-07-03 00:12:24.061258 |
description | An implementation of the polygon offsetting algorithm using winding numbers |
homepage | |
repository | https://github.com/anlumo/offset_polygon |
max_upload_size | |
id | 145540 |
size | 42,183 |
An implementation of the algorithm explained in Xiaorui Chen, Sara McMains: Polygon Offsetting Using Winding Numbers.
The winding number algorithm was adapted from this page, but read the Notes section.
The code itself was written by Andreas Monitzer andreas@monitzer.com.
It allows you to shrink and expand a polygon, like drawing an outline around it. It is also adding arcs to sharp corners with a parameter to control the number of arc points to add, since it outputs polygons only.
The crate uses geo-types in version 0.4 for its data types. The reason is that the author needs to integrate with geo-booleanop, but it's not really necessary for the operation itself.
There are a few magic numbers in the algorithm right now, including the winding number calculation. Initially I used the value returned by epsilon()
, but it turns out that this fails for a lot of cases (some of which are included as test cases). I don't know why this is, and this might be a problem for different scales. The values right now are optimized for the scale of pixels on a normal screen.
Just open up a ticket and/or a pull request on this github project. Make sure you explain what you want to do and why.
Licensed under either of
at your option.
Dual MIT/Apache2 is strictly more permissive