如何从一组无序点绘制多边形 [英] How to draw a polygon from a set of unordered points
问题描述
当前,我正在使用凸包算法从随机放置的一组点中获取最外面的点.我的目的是从凸包返回的一组点中绘制一个多边形,但是,当我尝试绘制多边形时,它看起来很奇怪.
Currently, I am using a convex hull algorithm to get the outer most points from a set of points randomly placed. What I aim to do is draw a polygon from the set of points returned by the convex hull however, when I try to draw the polygon it looks quite strange.
我的问题是,如何对点排序以便正确绘制多边形?
My question, how do I order the points so the polygon draws correctly?
谢谢.
此外,我尝试使用orderby(...).ThenBy(...)进行排序,但似乎无法正常工作.
Also, I have tried sorting using orderby(...).ThenBy(...) and I cant seem to get it working.
推荐答案
您是否尝试过礼品包装算法( http://en.wikipedia.org/wiki/Gift_wrapping_algorithm )?这应该以正确的顺序返回点.
Have you tried the gift wrapping algorithm ( http://en.wikipedia.org/wiki/Gift_wrapping_algorithm)? This should return points in the correct order.
这篇关于如何从一组无序点绘制多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!