pythonalgorithmgeometry

Is it possible to divide points to regions only based on their minimum distance to region-dividing curves?


I have a a set of scattered points with known coordinates on a plane (see schematic image), and four curves (C1-C4) that divide the whole plane into regions (R1-R5). I also know the minimum distance of each point to each curve. Is there a way to estimate which region the point falls into just based on this information? I would like to write code to do that in Python. My thinking is, to first find which minimum distance is the smallest for each point - that narrows down the options which region the point belongs to. But then how do I know which side of the curve the point falls on? For example, points A and B both have the smallest minimum distances d1 and d2 to curve C3, which would means they are either in region R3 or R4, but is there a way to narrow down which one? Curious to see if any solutions here are possible, or if more information is necessary to solve this problem. enter image description here

Edit: Here is an example code. I simplified it a bit. The data is stored in dataframe:

columns = ['Point', 'x', 'y', 'd1','d2','R']
data = [("A",1.5, 3.5, 1.2, 2.8, "NA"), ("B",3.5, 2.5, 0.8, 0.7, "NA"), ("C", 3.0, 0.5, 2.1,0.5,"NA")]
df = pd.DataFrame(data, columns=columns)

The region names are in a list:

regions=["R1","R2","R3"]

And output dataframe should be:

output_columns = ['Point', 'x', 'y', 'd1','d2','R']
output_data = [("A",1.5, 3.5, 1.2, 2.8, "R1"), ("B",3.5, 2.5, 0.8, 0.7, "R2"), ("C", 3.0, 0.5, 2.1,0.5,"R3")]
output_df = pd.DataFrame(output_data, columns=output_columns)

enter image description here


Solution

  • I don't think you can do it with the data provided, because the curve C4 (on the coloured diagram) could be really far away, making A very far from this C4, and closer to C2.

    I think you need to generate a new point, the one on C3, closest to A, call this point D.

    Addition of point D

    Then you can find distance of D->C4, compare it to A->C4 to determine the region of A.

    More generally I think you need at least one additional distance from a point you create based on A.

    Edit: I'm certain it isn't possible because this

    enter image description here has identical distances to this

    enter image description here

    But different regions