绘制可调整大小(不相交)的多边形 [英] Drawing resizable (not intersecting) polygons

查看:117
本文介绍了绘制可调整大小(不相交)的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处寻找,但找不到答案。 I
需要使用鼠标交互绘制可调整大小的多边形,但是
不希望在
端有不规则,重叠或相交的多边形。



下面是绘制可调整大小的多边形的简单示例
http://www.wolfpil.de /polygon.html



您可以轻松创建&调整很好的多边形。但是我需要额外的
功能来检测十字路口并且不允许奇怪的
看起来形状/多边形。
您可以在此视频中看到问题:
http:// www .youtube.com / watch?v = zou2jcGM8zw



我在 http://www.wikimapia.org 。他们增加了处理问题的功能。
您可以在此视频中看到: http:// www。 youtube.com/watch?v=K7-K0k2D-2A



我花了3天时间尝试实现这样的目标。我通过wikimapia的javascript代码获得了
,但对于我来说
理解太复杂了。总而言之,它不必像wikimapia那样看起来像花式一样。我只是
需要可调整大小的多边形,在调整大小时不会相交,或
为它添加新的点。你可以给我任何建议如何
实现吗?



预先感谢。

解决方案

取决于您允许的点数,简单的 O(N ^ 2) 行相交算法就足够了。从算法上来说,这不是最好的解决方案,但是对于初学者来说,它是计算几何中最容易获得的。

/en.wikipedia.org/wiki/Line_segment_intersectionrel =nofollow noreferrer>维基百科关于线段交集的文章。 它的一个链接有一个易于理解的解释来计算两条线段的交点。

祝你好运!


I have been searching everywhere but I could not find an answer. I need to have drawing resizable polygons with mouse interaction but I do not want irregular, overlapping or intersecting polygons in the end.

Here is a simple example of drawing resizable polygons http://www.wolfpil.de/polygon.html

You can easily create & resize polygons which is great. But I need an extra functionality to detect intersections and NOT allowing weird looking shapes/polygons. You can see the problem in this video: http://www.youtube.com/watch?v=zou2jcGM8zw

The only solution for that problem I found at http://www.wikimapia.org. They have added features to handle the problem. You can see it in this video: http://www.youtube.com/watch?v=K7-K0k2D-2A

I spent 3 days trying out to achieve something like this. I have gone through wikimapia's javascript code but it is way too complex for me to understand.

In sum, it does not have to look as fancy as as wikimapia's. I just need resizable polygons which do NOT intersect while resizing or adding new points to it. Can you give me any suggestions how to achieve that?

Thank in advance.

解决方案

Depending on how many points that you allow, a naive, simple O(N^2) line intersection algorithm suffices. Algorithmically this is not the best solution, but for starting out it's the most accessible for a beginner in computational geometry.

For starter, see Wikipedia article on line segment intersection. One of its links has an easy to understand explanation on how to compute the intersection point of two line segments.

Good luck!

这篇关于绘制可调整大小(不相交)的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆