Quadratic and Cubic Bezier Intersections
Sunday, May 19th, 2002The core intersection algorithms are now complete. The Intersection object has been updated to include the following intersections: Quadratic Bezier-Quadratic Bezier, Quadratic Bezier-Cubic Bezier, and Cubic Bezier-Cubic Bezier. You can see examples of these intersections in the 2D Geometry section of this site.
I managed to get my head around an approach that seems to work well for the various Bezier-Bezier intersections; however, there seems to be at least one case with the Quadratic Bezier-Quadratic Bezier intersection that I’m not handling properly. The problem case is when a Bezier overlaps itself and has all controls in a straight line. I was not able to reproduce the problem with the other two intersections, but I would imagine that there is a problem there too. BTW, if you want a good laugh, then you might want to look at the intersectBezier3Bezier3 method in the Intersection object. That has to be one of the most riduculous functions I’ve ever built in any language
.
There’s still plenty to do with the intersection algorithms. Mainly, I need to go back and revisit the code to see where I can optimize things a bit. For example, I know that I can add tests to see if two shapes have overlapping bounding boxes. This should speed up polygon and path intersections considerably. And I still need to take care of polylines, horizontal and vertical lines in paths, and probably more.