Closed videlec closed 1 year ago
The polygon in question is Polygon(vertices=[(0, 0), (-3, 0), (-3/2, 1/2*a)])
. It's created from "edges" [(-3, 0), (3/2, 1/2*a), (3/2, -1/2*a)]
.
This happens while triangulating the polygon Polygon(vertices=[(0, 0), (3/2, 1/2*a), (3, 0), (9/2, 1/2*a), (4, a), (3, a), (3, 2*a), (3/2, 5/2*a), (1, 2*a), (0, 2*a), (0, a), (-3/2, 1/2*a), (-1, 0)])
, aka
We try to create a polygon from the vertices 0, 1, 2. And that's indeed not convex.
It's a bit bizarre that this is not using the triangulation of the polygon but that surfaces are implementing their own triangulation.
So, triangulating an infinite surface uses polygon triangulation but finite surfaces implement it on their own :shrug:
Anyway, this is the fix:
diff --git a/flatsurf/geometry/surface.py b/flatsurf/geometry/surface.py
index 096c6ee..2e26f70 100644
--- a/flatsurf/geometry/surface.py
+++ b/flatsurf/geometry/surface.py
@@ -2056,7 +2056,7 @@ class MutableOrientedSimilaritySurface(
for i in range(n):
e1 = poly.edge(i)
e2 = poly.edge((i + 1) % n)
- if ccw(e1, e2) != 0:
+ if ccw(e1, e2) > 0:
# This is in case the polygon is a triangle with subdivided edge.
e3 = poly.edge((i + 2) % n)
if ccw(e1 + e2, e3) != 0:
See eg #238.
Even though triangulation of non-convex polygons seem to work: