将一维函数简化为点数较少的折线的算法

Algorithm for reducing 1D function to polyline with small number of points

提问人:Jan Spurny 提问时间:11/5/2019 最后编辑:Jan Spurny 更新时间:11/5/2019 访问量:357

问:

问题

我的输入是一维函数,我想找到一种方法来近似这个函数,在某个给定的间隔上有一个点数很少的折线:y = f(x)<x1, x2>

enter image description here

我试过什么:

我通过制作具有许多点 (1000+) 的折线,然后使用 Ramer-Douglas-Peucker 算法抽取这条折线来解决这个问题。

enter image description here

所以在(伪)python中,它会是这样的:

def fn_to_low_poly(f, x1, x2):
    xs = numpy.linspace(x1, x2, 1000)
    ys = f(xs)
    return ramer_douglas_peucker_decimate(xs, ys, epsilon=0.001)

这可行,但它太复杂和缓慢了,我很确定一定有更好的方法。

我现在正在 python/numpy/scipy 中执行此操作,但我可能需要用 C 或 Rust 或其他语言重写它,所以我不太关心在 python 中解决这个问题的具体方法,我宁愿有一个通用算法,尽管我会感谢任何帮助。

问题:

有没有一种算法可以直接将一维函数()简化为点数较少的折线?float -> float

Python 算法 折线 下采样 抽取

评论

2赞 High Performance Mark 11/5/2019
您可能正在寻找图形 Gem 论文 Adaptive Sampling of Parametric Curves。让你的搜索引擎成为你的朋友。
0赞 Jan Spurny 11/5/2019
@HighPerformanceMark看起来不错——我知道我想要什么,但我不知道该搜索什么。谢谢。

答: 暂无答案