algorithmgdihit

Check if a point belongs to area enclosed by Bezeir curve using GDI


I want to check if a specified coordinate is inside an area enclosed by a Bezier curve. Is there specific function in GDI I can use? If no, how could I do this manually? My Bezier curve sets by its points.


Solution

  • How much queries are you going to do?
    If performance is not very important, you may create GDI region and check whether point is inside:

    BeginPath
    draw enclosed path with PolyBezier and other functions
    EndPath
    PathToRegion
    PtInRegion
    

    If there are many query points, it would better to make analytic solution - calculate the number of intersections of (horizontal) ray from point with Bezier curve (cubic equation solution is needed). If this number is odd - point is inside (there are some subtleties with double roots on curve cusps etc)