Control point inside the form
I am looking for a point inside or outside the Polygon algorithm. So far I have found some algorithm (odd even rule algorithm) and that works successfully if I pass the points of the polygon. But for this I ran into a problem (for calculating points). The problem is that the polygon only contains movement and data binding (for example, if the polygon is a rectangle or octagon, etc.), then I can easily calculate the drawing points of the Polygon. But I have a polygon that can draw using arc data as well as line and move to data. So in this case I am stuck for checking a point inside or outside of a polygon in general.
Here I am attaching some polygon images.
You can see the above image, which draws using a line, will move in the same way as the arc data. So in this scenario, I cannot verify.
Please give some idea on how I can check a point inside or outside this type of polygon?
(For drawing a polygon, I have data something like this:
MoveTo: Coordinate: 424.941955, 626.04046,
LineTo: Coordinate: 428.941955, 626.04046,
ArcTo: Coordinate: 431.941955, 633.04046 - Center Point: Coordinate: 433.941955, 628.04046 - Angle: -1.5707963267948966,
LineTo: Coordinate: 431.941955, 639.04046,
ArcTo: Coordinate: 428.941955, 646.04046 - Center point: Coordinate: 433.941955, 644.04046 - Angle: -1.5707963267948966,
LineTo: Coordinate: 424.941955, 646.04046,
ArcTo: Coordinate: 421.941955, 639.04046 - Center: Coordinate: 419.941955, 644.04046 - Angle: -1.5707963267948966,
LineTo: Coordinate: 421.941955, 633.04046,
ArcTo: Coordinate: 424.941955, 626.04046 - Center: Coordinate: 419.941955, 628.04046 - Angle: -1.5707963267948966)
These are approximation data.
Thank.
You have to do the same algorithm (even-odd), but you need to use a different intersection algorithm for arcs (bezier curves).
Here's a blog post that should start working in the right direction: https://www.particleincell.com/2013/cubic-line-intersection/
Update:
Here is an answer and a question on how to make a line / circle intersection. It should be pretty trivial to check if the intersection points are within your level.
source to share
Since you were asking for ideas, you have the following options that I can think of:
-
Do as Ranis suggested. This is the best.
-
Create temporary polygons that approximate the curves using straight line segments and then use the existing algorithm. This is suboptimal, but depending on the specifics of your situation, this can be a pragmatic approach.
-
Rasterize the shapes using different foreground and background colors, and then just check the color of the pixel under the point. This is highly sub-optimal, but if you accidentally already rasterize these shapes to display them, then you already have everything you need to quickly complete this task.
source to share