Reputation: 89
I'm looking for an algorithm which could create shapes based
on arrays with coordinates. I have two 50
x50
arrays: one with x and second with y coordinates.
There is always 2500
points. Then I have another 50
x50
array with my values for coordinates.
I create 3 to 6 areas based on value (for example 0-100, 200-300 and 300-500). Points with certain values creates areas.
I need an algorithm which can calculate if there is only one shape in area or more and fill shapes with colors. I need that because I must fill shapes with certain colors for each area. Language is C#.
Upvotes: 4
Views: 356
Reputation: 7817
Basically you could use hierarchical clustering to find the clusters.
Couple of specifics: In step 2 you could use many metrics to find the closest clusters. Mean-to-mean distance or minimum distance over all point pairs are probably best choices
In Step 3, you can either stop when remaining number of clusters is 2 (or some other number). Or stop when distance is more than a threshold.
To find the actual outline, I suggest coming up with some optimization function that minimizes the length of outline while minimizing the area of the outline. And the some heuristics to optimize the function.
Something like Area - constant*Length.
Upvotes: 1