Unify fails when polygons are wound in opposite directions
See original GitHub issueIf two polygons are constructed, the first in a CCW direction and the second in a CW direction, the resulting union is not correct:
const polygon1 = new Polygon();
polygon1.addFace([point(0, 0), point(10, 0), point(10, 10), point(0, 10)]);
const polygon2 = new Polygon();
polygon2.addFace([point(8, 2), point(8, 8), point(20, 8), point(20, 2)]);
const result = unify(polygon1, polygon2);
// result is not the expected shape
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Extend 2d polygon by vector - Stack Overflow
It is part of my Polygon class, which has a std::vector of counterclockwise-wound vertices. units::Coordinate are floats, ...
Read more >Chapter 11 - OpenGL Programming Guide
This chapter has the following major sections. "Polygon Tessellation" explains how to tessellate convex polygons into easier-to-render convex polygons. " ...
Read more >Boston Scientific Corp. v. Cook Inc., 187 F. Supp. 3d 249 (2016 ...
“wound helically,” “wound in opposite directions,” and “a strand wound helically in a direction [different from the first direction]” ...292.
Read more >Why should polygons in 3D models have no more than 4 sides?
Nothing is done to the intersections to blend the shapes and merge the vertices. The image on the right shows that the branch...
Read more >Fill paths for one slice of the part shown in Fig. 1(a); | Download ...
Internal contours are buffered in the opposite direction to the commanded buffering direction. ... This reduces the number of polygons to merge by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, David, Flatten-js support multi-polygons, comprised from a number of faces, some of them may be external, some internal. Internal faces represent holes - cut-off areas inside a polygon, and their orientation should be opposite to the outer polygon they belong.
unify
(and other boolean operations) assume that both polygons have same meaning of orientation, for example, in both polygons outer faces oriented counterclockwise, and inner faces oriented clockwise. Best regards, AlexI have a method
polygon.splitToIslands()
which returns an array of polygons, where each polygon is ordered by inclusion of faces: the first face is an outer (we call it “island”) and the others are internal (we call them "holes). You can use it before and afterunify
, becauseunify
indeed does not keep an order of faces. I can also add a method that rearrange faces in polygon in the way that island always precede holes, if it may help Best, Alex