3 ms·
Algorithms that gave me floating-point related problems: - Fast polygon triangulation/partitioning. There's a reason why people use ear clipping in practice de
by pcwalton 7y ago
Algorithms that gave me floating-point related problems:
- Fast polygon triangulation/partitioning. There's a reason why people use ear clipping in practice despite it having bad asymptotic time complexity. Even ear clipping isn't very useful for robust path rendering because it doesn't handle self-intersection. Tiling and stenciling to compute winding numbers is a much more robust approach than tessellation.
- Generation of bounding geometry for analytic antialiasing of polygon edges, to work around the lack of conservative rasterization on GPUs. Skia has impressive code that handles this, but it is incredibly painful and I decided it wasn't worth it.
- Determining polygon convexity. This even led to a security bug in Skia [1].
- Clipping of Bézier paths, especially in homogeneous coordinates. Yes, this even includes clipping to axis-aligned rects. It's too hard. Convert to triangles or quads and clip those.
- Any sort of Boolean operation on Bézier paths, if you want reliable results. Leave those to applications like Illustrator, where artists can notice if the algorithm goes wrong and fix it up manually when it does.
[1]: https://googleprojectzero.blogspot.com/2019/02/the-curious-case-of-convexity-confusion.html https://googleprojectzero.blogspot.com/2019/02/the-curious-c...