Bezier Intersections

BlitzPlus Forums/BlitzPlus Programming/Bezier Intersections

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I haven't written this type of code, but my approach would be to write a function that converges on the approximation of where the bezier curve and the line segment intersect.

Here are links to code to get you started
Bezier Code: http://blitzbasic.com/codearcs/codearcs.php?code=170

Line-Line Intersect: http://blitzbasic.com/codearcs/codearcs.php?code=1202

For example:
Using only 10 points to plot your bezier curve, test each line segment between the ten points until you determine if the bezier and line segment intersect using line-line intersect code.

If the lines intersect you know approximately where they intersect. This may be good enough at this rough scale, again depending on how accurate you need to be.

Otherwise, increase the number of segments in your bezier to 100 points, 1000 points (and so on...) and continue looking for line-line intersects until you zero in on the most accurate coordinates.

Good Luck,

Andy