从多点创建多边形的算法VB6
我正在尝试使用多边形函数在 VB6 中创建多边形。
我有很多随机顺序的点,我想用它们来创建多边形。
不幸的是,在开发多边形时,顺序很重要,因为我得到的是锯齿状的多边形,而不是漂亮的闭合多边形。
我想知道是否有人有任何好的想法/技巧来开发一种可以遍历这些点并将它们按适当顺序排列的算法。
非常感谢!
I am trying to create a polygon in VB6 using the polygon function.
I have many points in random order that I would like to create the polygon with.
Unfortunately, the order is important when developing a polygon, as i get a jagged looking polygon, as opposed to a nice closed polygon.
I was wondering if anyone had any good ideas/tricks to develop an algorithm that can go through these points and put them in an appropriate order.
Thanks so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使事情简单且解决方案独特,您应该从像这样的凸包算法(“礼品包装”)开始:
http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
在 VB 中实现应该不会太难。如果您对此有疑问,请提出新问题。
To keep things simple and the solution unique, you should start with a convex hull algorithm like this one ("Gift Wrapping"):
http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
Should not be too hard to implement in VB. If you have problems with that, ask a new question.
我使用格雷厄姆扫描算法来实际解决这个问题。
http://en.wikipedia.org/wiki/Graham_scan
如果您遵循伪代码,请小心。
该行
应该是
I used the Graham Scan Algorithm to actually go ahead and solve this problem.
http://en.wikipedia.org/wiki/Graham_scan
If you follow the pseudocode, be careful.
The line
Should be