How to find intersection points between two cubic bezier curve

Swarnendu Paul picture Swarnendu Paul · Apr 17, 2013 · Viewed 7.9k times · Source

I have two cubic bezier curve,

curve 1:- 1st anchor-point(a1x,a1y), 1st control-point(c1x,c1y), 2nd control-point(c2x,c2y), 2nd anchor-point(a2x,a2y)

curve 2:- 1st anchor-point(a3x,a3y), 1st control-point(c2x,c3y), 2nd control-point(c4x,c4y), 2nd anchor-point(a4x,a4y)

Now I want to find the intersection points between these two bezier curve;

How to do it? Any reference document with algorithm will help me;

Answer

MBo picture MBo · Apr 17, 2013

There are two main methods to find a Bezier curve intersection:

  1. Recursive subdivision exploits the convex hull property of Bezier curves and usually checks the intersection of bounding boxes of its curve segments.

Code from book Graphics Gems IV with some textual description

  1. Numerical solution of the system of two cubic equations. It leads to a polynomial equation of the 9th order and may have 9 real roots (case of two S-shaped curves). Note that the solution is numerically unstable.

JS code and interactive demonstration And I think C++ code might be in Geometric Tools WildMagic library.