简体   繁体   English

查找顶点边(多边形)的最佳算法

[英]Best Algorithm to find the edges (polygon) of vertices

I have a large array of vertices, some of them are edges, some are redundant (inside the shape) and I want to remove those. 我有一大堆顶点,其中一些是边,一些是冗余的(在形状内)我想删除它们。

The simplest algorithm I could think of is checking one by one if they hit the shape formed by the others. 我能想到的最简单的算法是,如果它们碰到其他人形成的形状,则逐个检查。 But it should be a very slow algorithm. 但它应该是一个非常慢的算法。

I thought about picking one from the edge (the one farthest from origin per example) and calculate the longest path from this start... should get the edge path, right? 我想过从边缘挑选一个(距离每个例子最远的一个)并计算从这个开始的最长路径...应该得到边缘路径,对吗?

Any suggestion? 有什么建议吗?

The trick with polyhedral algorithms is choosing one that fits with your input and your desired output, since there is more than one way to represent a polyhedron and converting between the representations can be expensive. 多面体算法的技巧是选择一个适合您的输入和所需输出的技巧,因为有多种方法来表示多面体,并且表示之间的转换可能很昂贵。 In this case, you are starting with points and want to end with vertices, so the Graham scan algorithm to compute the vertices of the convex hull should do the trick, though it might take some effort to extend it past the 2-D case. 在这种情况下,您从点开始并希望以顶点结束,因此用于计算凸包顶点的Graham扫描算法应该可以解决问题,尽管可能需要花费一些精力才能将其扩展到2-D情况。 It's O( n log n ) in the number of input vertices. 它是输入顶点数量的O( n log n )。

I do not know what the best algorithm to find that polygon is, but the polygon you are looking for is called "Convex Hull". 我不知道找到该多边形的最佳算法是什么,但您正在寻找的多边形称为“凸壳”。

By searching for that, you should find a matching algorithm. 通过搜索,您应该找到匹配的算法。

The Convex Hull is one of the more researched problems of Computational Geometry. Convex Hull是计算几何中研究较多的问题之一。 The Graham Scan is one of the simpler convex hull algorithms , but certainly not the only one. Graham Scan是一种更简单的凸壳算法 ,但肯定不是唯一的算法 The Gift-wrapping Algorithm , also called Jarvis' March, is the simplest I know of. 礼品包装算法 ,也称为贾维斯三月,是我所知道的最简单的。 The Stony Brook algorithm repository has several implementations of convex hull algorithms in C and C++. Stony Brook算法库在C和C ++中有几种凸包算法。 Geometry in Action shows mainly applications of convex hulls. 几何在行动中主要显示凸壳的应用。 Here's a collection of low-dimensional and arbitrary-dimensional convex hull calculating programs. 这是一组低维任意维凸壳计算程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM