开发者

Algorithm to find figures using input points

I have just discussed with student and he told me him t开发者_开发问答ask, and I think it is interesting. The task. There are file with points like:

Point0: x=1; y=4;
Point1: x=199; y=45;
Point2: x=42; y=333;
Point3: x=444; y=444;
...
PointN: x=nnn; y=mmm;

You should find polygons and draw them. Each polygon present as internal I mean something like this:

---------
| -----  |
| |    | |
| |----| | 
|        |
|--------|

And question what algorithm can you advice to use in this case? I understand this is from graph theory , but want opinion of other. Thanks.


Idea: Find the convex hull of all the points. For all the points that do not belong to the hull repeat the algorithm until no points left.


You could probably find a distance matrix for all the points and then do iterations like the following:

  1. Find the largest distance
  2. Draw rectangle for the two points which correspond to the found distance
  3. Remove these points from the list
  4. Repeat
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜