English 中文(简体)
为封闭式多管构体的Douglas-Peucker算法寻找好的起点
原标题:Finding good starting points for Douglas-Peucker algorithm for closed polygons

我正试图减少使用Douglas-Peucker算法的多功能中转器,该算法对线路和路子做了相当的罚款。

我的问题是,我希望最优化的多种渠道已经关闭。 在选择2个随机相邻点时,优化运转良好,但起点和终点除外,因为它们是固定的,可以优化。

是否有选择起点的良好办法?

问题回答

我只是随意选择一个要点(例如,所有要点清单中的“第一”点),并找到最严峻的点。 这类似于从线段寻找最远点时算法的普通步骤。

我也许会在这里完全曲解这一问题,但正如你刚才想把Douglas-Peucker算法(http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)调整到多角。 你只能把多角视为与起点和终点一致的唯一理由是,算法要求你区分这两点。

因此,我建议在座右翼上挑出两点任意,两点相距甚远,然后把Douglas-Peucker algorithm开两倍,两点一朝一路,两点 points,一朝一路,两点 points。

Your arbitrary points are guaranteed to be in the final solution, but otherwise its as close as you can get to the line approximation of the algorithm.

如果这只字不提,你就应当寻找解冻层或尾矿层,因为这个问题一般在计算机图表中提出,尽管你可能会用相当复杂的树结构,对多印度人解决问题,而这种结构可能不是你所期望的。

我在javascript的图书馆也做了类似的事情,在那里,我发现两点相互距离最远,并利用这两点来优化多功能。

在这里,我相信,你能够适应你使用的任何语言:

function polygonPeuckerReduce(path, tolerance) {
    var points = [];
    if (path.length < 3) {
        return points.concat(path);
    } else {
        var widest = 0.0, startIndex = 0;
        // find the widest part of the polygon (only start index is necessary)
        for (var i = 0, l = path.length; i < l; i++) {
            var point = path[i];
            for (var j = i + 1; j < l; j++) {
                var distance = point.distanceTo(path[j]);
                if (distance > widest) {
                    startIndex = i;
                    widest = distance;
                }
            }
        }

        // re-order the points with the new starting point (faster method)
        points = path.splice(startIndex, path.length).concat(path);

        return PEUCKER_INTERNAL(points, tolerance); // the magic
    }
}

另一种可能性是,通过所有三套连续的曲线进行扫描,并从连接其前身和后继器的线中提取两套,即收集原始数据集中属于两个最大角落的两条vert。 这两部vert,然后将Douglas-Peucker应用于中间vert。

This can be noisy if all your points are closely spaced. In that case rather than simply consider successive sets of three vertices, you can work outward in both directions from each input vertex, using Douglas-Peucker to skip over unnecessary vertices in each direction. This will result in larger, more-widely-spaced triples. Again find the two vertices that are furthest from the lines joining the predecessor/successor vertices, fix those, and apply Douglas-Peucker to the intervening vertices.

其他变化是可能的,但这应比其他答复中描述的“土地”或“最相距”的起点更好。





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签