Closed MaikuMori closed 3 years ago
Hi @MaikuMori ,
Bug fixed, hope it works better now.
Use version @flatten-js/polygon-offset@1.1.3
and install @flatten-js/core@1.2.24
as a peer dependency.
Thank you for collaboration, please report other issues you meet
Best, Alex
Looks like it's working. Meanwhile, I implemented my own dumber version which moves each line (edge) inwards and extends it and then on 2nd pass clips them at intersecting points. It worked out for the simple polygons that I need to deal with.
I might come back to using the lib now.
Hi @MaikuMori ,
Just wanted to say that your pair-wise offset algorithm is not dumb. It fast and works perfect for convex polygon. But note that it is not equidistant. The distance between convex vertex and its offset is greater than the offset value. If this is what you need this is ok. Here I suggested the version of equidistant offset or dilation, where each point of the offset polygon is on exact offset distance from the original one. It does not preserve convex vertices and map them to circular arcs.
Best, Alex Bol
Certain set of points never get correct offset.
I'm adding a demo showcasing how scaling the same polygon and then getting offset from it will sometimes work and sometimes not.
https://observablehq.com/d/c833c430655e7618
Am I doing something wrong? I know that for polylines I can probably use a more simple algorithm, but I'm using
flatten-js
for some other things. Also, for my use case I need a small offset (-2), it does seem to work better with a bigger offset.