GDI+: intersection with bezier curves?
Hi,
Can anyone tell me/direct me to links on how to detect if a mouse click (or some coordinate) is within a drawn Bezier curve? I'm currently drawing a bunch of them on a form, and would like to know if there's anyway at all to find out if a mouse-click event has occured, and which curve was selected.
Thanks.
using: Visual C++ 2003
Any suggestions anyone?
In case it wasn't clear enough, to draw my bezier curves, the only data that I'm storing are 4 points, and the actual curve itself is drawn using Graphic's DrawBezier function.
Is my only option to calculate the bezier curves from the set of 4 points and checking if a given point is intersecting/in the curve? Or are there any other methods?
Please help.
Thanks.
Just a side comment that not directly to the question, I think checking a given point is intersecting in the curve is not practically applicable, since pixels are not points. In graphical scenarios, a proper way is define a minimum distance, let's say: Delta, find a algorithm to calculate the minimum distance between a known point and a known bezier curve(I am sure the algorithm is somewhere), let's say the minimum distance is: Alfa, now the conditional statement looks like this:
Code Snippet
if( Alfa < Delta ){
// consider the point is on the bezier curve
}
else{
// the point is not on the bezier curve
}
hope it helps
rico
Hi,
Thanks for the replies!! Was thinking that no one else would've replied. Anyway, I've settled with just calculating the midpoint of the curve, and placing a small rectangle there instead. With that, I'm now able to just select the line by selecting the rectangle. But anyway, I really appreciate the help and suggestions. If I have more time, will definitely revisit this and get it working completely.
Thanks again