在Java / Android的使用给定的点绘制凸包 [英] Draw a convex hull using the given points in java/android
问题描述
我已经给出了一些2D点,我想提请使用这些点的多边形。此多边形必须经过所有的给定点装置不存在这样的点,这是内部或多边形外
例如:如果我有像点(0,0),(1,1),(1,-1),( - 1,1)和(1,-1),如果我想绘制使用这些话我点阵列多边形应当按以下方式进行排序:
(1,1) - >(1,-1) - >(-1,-1) - >(-1,1) - >(0,0) - >(1,1)或者
(1,1) - >(0,0) - >(-1,1) - >(-1,-1) - >(1,-1) - >(1,1)对>
但它不能是:
(1,1) - >(0,0) - >(-1,-1) - >(-1,1) - >(-1,1) - >(1,-1) - > (1,1)
有关绘制多边形,我使用<一个href=\"http://developer.android.com/reference/android/graphics/Canvas.html#drawLine%28float,%20float,%20float,%20float,%20android.graphics.Paint%29\"相对=nofollow>的drawLine 功能,从一个到另一个点,终于到第一点绘制线条从去年。
有没有一个适合这个任何算法或code?
谢谢!
我觉得你的问题并不像看上去的那样微不足道。恕我直言其旅行商问题,但不相交路径的一种特殊形式。
I have some 2D points given and i want to draw a polygon using those points. This polygon must pass through all the given points means there is no such point which is inside or outside the polygon.
For example: if i have points like: (0,0), (1,1), (-1,-1),(-1,1) and (1,-1) and if i want to draw a polygon using those then my points array should be sorted in following manner:
(1,1) -> (1,-1) -> (-1,-1) -> (-1,1) -> (0,0) -> (1,1) OR
(1,1) -> (0,0) -> (-1,1) -> (-1,-1) -> (1,-1) -> (1,1)
but it cant be:
(1,1) -> (0,0) -> (-1,-1) -> (-1,1) -> (-1,1) -> (1,-1) -> (1,1)
For drawing the polygon, i am using drawLine function and drawing lines from one to another point and finally from last to first point.
Is there any algorithm or code available for this?
thanks!!
I think your problem is not as trivial as it seems. IMHO its a special form of the travelling salesman problem, but without intersecting paths.
这篇关于在Java / Android的使用给定的点绘制凸包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!