schnittp - crossing points of two curves
This function calculates the crossing points of two curves. Therefore, curve segements by sequential points are rebuild as lines and a mathematical solution is derived. Q contains in the 1st row the crossing points, the 2nd row contains the direction vector and the last row the index ps of curve 1, so that the crossing points can also be calculated by C1(ps) + Q(3,ps)*(C1(ps+1)-C1(ps))
z1=bezier(); // Draw Curve 1, finish with right click (twice) z2=bezier(); // Draw Curve 2, finish with right click (twice) // Calculating... please wait Q=schnittp(z1,z2); plot2d(real(z1),imag(z1),style=2); plot2d(real(z2),imag(z2),style=3); plot2d(real(Q(1,:)),imag(Q(1,:)),style=-3); // Draw both curves and common points in a graph