adamwulf / ClippingBezier

ClippingBezier calculates intersection points, paths, and shapes between two UIBezierPaths
http://getlooseleaf.com/opensource/
MIT License
254 stars 34 forks source link

Intersection exception #24

Open FabioTacke opened 2 years ago

FabioTacke commented 2 years ago

I use the library to calculate intersections of UIBezierPaths. In some cases I run into the BezierPathIntersectionException (mismatched intersection length) when intersecting paths with almost identical path segments.

I've added a test case that reproduces the exception. From briefly looking into the algorithm I don't understand what's going wrong here. I would be glad if you could take a look into it.

It might be the same issue as what's causing #9.

Thanks!

adamwulf commented 2 years ago

Big thanks for the test case! I don't have time in the near-term to look into this, but when I finally do get time that test will be a big help. I think you're right that this is #9 as well.

TianLong1989 commented 2 years ago

This is big issue in my app. When can you see this bug and resolve problem?

adamwulf commented 2 years ago

Hi @TianLong1989, unfortunately I wont have time to fix this in the near term. Depending on your paths, you might be able to scale them up by 10 or 100, run the clipping, and scale the results back down. i know that's also not ideal, but could possibly resolve the issue for you in some cases.

adamwulf commented 1 month ago

test case from the Arclite referenced above:

(lldb) po textPath
path = UIBezierPath()
path.move(to: CGPoint(x: 148, y: 1422))
path.addLine(to: CGPoint(x: 148, y: 1456))
path.addLine(to: CGPoint(x: 153, y: 1456))
path.addLine(to: CGPoint(x: 153, y: 1422))
path.close()

(lldb) po wordPath
path = UIBezierPath()
path.move(to: CGPoint(x: 93.3019079008692, y: 1422.00000072504))
path.addLine(to: CGPoint(x: 93.3019079008692, y: 1467.087208519229))
path.addLine(to: CGPoint(x: 1164.245267275869, y: 1467.087208519229))
path.addLine(to: CGPoint(x: 1164.245267275869, y: 1422.00000072504))
path.close()