Question

I need a way to check, whether user clicked a Bezier spline. My current approach is to split it to segments and then check, whether the hit point is near enough to one of these segments (near enough in terms of mathematical point-to-segment distance method). But this method has its drawbacks:

Bezier selection

As you see, points marked by red dots will not be treated as active, though they should be. Of course, I can increase number of segments, but that will actually make the solution worse, because there will be a lot more gaps between active areas.

How can I reliably check, whether user clicked area near Bezier spline?

Note, that I post this on StackOverflow instead of its Math counterpart, because I actually need more reliable heuristics than mathematical solution (the latter mostly probably will be to slow to be used in my program, these checks have to be done in real time, during mouse move).

Was it helpful?

Solution

What about adding point-point distance calculation between the red dots and the line segment cross points? With the same distance you use in the point-to-segment distance calculation, it should fill the gaps and work better.

enter image description here

OTHER TIPS

This should have been a comment, but I'm not yet allowed to comment, so I post it as answer.

Have you tried measuring against the control point polygon of the bezier curve instead of the bezier curve itself? A bezier curve lies inside the convex hull of its control points. If your bezier curves are not too close to each other it might be sufficient to check if the user clicked inside (or close to) the hull of the control points.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top