Pomax / bezierjs

A nodejs and client-side library for (cubic) Bezier curve work
MIT License
1.75k stars 235 forks source link

Circle intersection #39

Closed danmarshall closed 8 years ago

danmarshall commented 8 years ago

Hi Mike, What is a good strategy for detecting intersection of a Bezier curve and a circle? Would you recommend using 4 curves, each approximating a quarter circle?

Pomax commented 8 years ago

Given the high number of intersections, I'd probably recommend doing bounding box iterations, much like for regular curve/curve intersection testing. A circle and a cubic curve can have up to six intersections, so iteratively splitting the curve into subcurves and the circle into arcs, then weeding out parts without bounding box overlaps and redividing the parts that do, is a cheap way to find all intersections, reasonably fast, and reasonably accurately.