对轨迹进行重新采样,使每个样本中的欧氏距离相等

2023-12-11

假设我们有一个 x,y 点列表:

x = [0, 0, 0]
y = [0, 10, 100]

点之间的欧几里得距离现在为 [10, 90]。
我正在寻找一个接受x、y 和sample_rate 的函数,并且可以输出相等的距离点。例如。:

x = [0, 0, 0]
y = [0, 10, 100]

resample_distance = 10
resampler(x, y, resample_distance)
# Outputs:
# [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
# [0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0]

使用类似的answer,我们可以获得几乎正确的值,但这并不准确:

resample_trajectory_same_distance(data[0], data[1], 10)
# Output:
# [ 0.        , 10.27027027, 20.81081081, 31.08108108, 41.62162162, 51.89189189, 62.43243243, 72.7027027 , 83.24324324, 93.78378378]
# [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]

使用任何第三方库(如 numpy、scipy 等)都可以。


我实施了下一个解决方案。

所有提高效率的函数都是由Numba编译器/优化器支持准时制/提前时间技术。 Numba 转换所有标记为@numba.njit装饰器函数要纯C/C++每当Python代码启动时,C++代码就会自动编译为机器代码。这些函数中没有与Python进行交互,内部仅使用低级快速结构。因此,Numba 通常能够提高几乎所有代码的速度50x-200x平均次数,非常快!此类 Python 编译代码的速度通常非常接近于纯 C/C++ 中手动实现的相同算法的速度。要使用 Numba,只需安装接下来的两个 python 包:python -m pip install numpy numba.

接下来的步骤在我的代码中完成:

  1. 输入函数由两个一维数组表示x and y.
  2. 输入函数(点)为近似值(或以不同方式称为插值) 通过两种分段函数之一 - 1)Linear 2) 三次样条.
  3. 线性分段逼近函数仅连接给定的点数组(x0, y0)所以这对两个连续点(x1, y1) and (x2, y2)由直线(线段)连接。
  4. 三次样条是平滑逼近函数的更高级方法,它连接所有点(x0, y0)使得每对点(x1, y1) and (x2, y2)由立方线段连接,表示为三次多项式这样它经过这两个端点加上公共点内相邻段的一阶和二阶导数相等,这些都确保函数看起来非常平滑和漂亮,并且在计算机图形学中非常流行,用于进行自然/真实的近似/可视化功能/表面。
  5. 然后使用速度非常快二分查找算法我正在这个插值函数上逐一搜索点,这样的点欧氏距离每两个连续点之间的值恰好等于所需的(提供给算法)值d.
  6. 以上只是计算部分。其余步骤将部分可视化,使用绘图matplotlib图书馆。绘图的详细描述位于绘图之前的代码之后。

为了使用这个实现的欧几里德等距离重采样算法,您只需要import我的下一个脚本模块,然后做xr, yr = module_name.resample_euclid_equidist(x, y, dist)其中输入和输出x and y都是具有浮点数的一维 numpy 数组,这将返回在以下位置重新采样的输入点dist欧几里得距离。更多使用示例位于我的代码中test()功能。第一次运行非常慢(可以花大约15秒),这次运行只是编译运行,我的所有代码都会自动预编译为 C/C++,然后是机器代码,接下来的运行速度非常快,尤其是重采样函数本身只需要几毫秒。另外,要仅使用代码的计算部分,您需要安装python -m pip install numpy numba,并运行我的整个代码,包括测试和可视化(只需运行我的脚本),您需要安装python -m pip install numpy numba matplotlib就一次。

在线尝试一下!

# Needs:
#     For computation: python -m pip install numpy numba
#     For testing:     python -m pip install matplotlib

if __name__ == '__main__':
    print('Compiling...', flush = True)
    
import numba, numpy as np

# Linear Approximator related functions

# Spline value calculating function, given params and "x"
@numba.njit(cache = True, fastmath = True, inline = 'always')
def func_linear(x, ix, x0, y0, k):
    return (x - x0[ix]) * k[ix] + y0[ix]
    
# Compute piece-wise linear function for "x" out of sorted "x0" points
@numba.njit([f'f{ii}[:](f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:])' for ii in (4, 8)],
    cache = True, fastmath = True, inline = 'always')
def piece_wise_linear(x, x0, y0, k, dummy0, dummy1):
    xsh = x.shape
    x = x.ravel()
    ix = np.searchsorted(x0[1 : -1], x)
    y = func_linear(x, ix, x0, y0, k)
    y = y.reshape(xsh)
    return y
    
# Spline Approximator related functions
    
# Solves linear system given by Tridiagonal Matrix
# Helper for calculating cubic splines
@numba.njit(cache = True, fastmath = True, inline = 'always')
def tri_diag_solve(A, B, C, F):
    n = B.size
    assert A.ndim == B.ndim == C.ndim == F.ndim == 1 and (
        A.size == B.size == C.size == F.size == n
    ) #, (A.shape, B.shape, C.shape, F.shape)
    Bs, Fs = np.zeros_like(B), np.zeros_like(F)
    Bs[0], Fs[0] = B[0], F[0]
    for i in range(1, n):
        Bs[i] = B[i] - A[i] / Bs[i - 1] * C[i - 1]
        Fs[i] = F[i] - A[i] / Bs[i - 1] * Fs[i - 1]
    x = np.zeros_like(B)
    x[-1] = Fs[-1] / Bs[-1]
    for i in range(n - 2, -1, -1):
        x[i] = (Fs[i] - C[i] * x[i + 1]) / Bs[i]
    return x
    
# Calculate cubic spline params
@numba.njit(cache = True, fastmath = True, inline = 'always')
def calc_spline_params(x, y):
    a = y
    h = np.diff(x)
    c = np.concatenate((np.zeros((1,), dtype = y.dtype),
        np.append(tri_diag_solve(h[:-1], (h[:-1] + h[1:]) * 2, h[1:],
        ((a[2:] - a[1:-1]) / h[1:] - (a[1:-1] - a[:-2]) / h[:-1]) * 3), 0)))
    d = np.diff(c) / (3 * h)
    b = (a[1:] - a[:-1]) / h + (2 * c[1:] + c[:-1]) / 3 * h
    return a[1:], b, c[1:], d
    
# Spline value calculating function, given params and "x"
@numba.njit(cache = True, fastmath = True, inline = 'always')
def func_spline(x, ix, x0, a, b, c, d):
    dx = x - x0[1:][ix]
    return a[ix] + (b[ix] + (c[ix] + d[ix] * dx) * dx) * dx
    
# Compute piece-wise spline function for "x" out of sorted "x0" points
@numba.njit([f'f{ii}[:](f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:])' for ii in (4, 8)],
    cache = True, fastmath = True, inline = 'always')
def piece_wise_spline(x, x0, a, b, c, d):
    xsh = x.shape
    x = x.ravel()
    ix = np.searchsorted(x0[1 : -1], x)
    y = func_spline(x, ix, x0, a, b, c, d)
    y = y.reshape(xsh)
    return y
    
# Appximates function given by (x0, y0) by piece-wise spline or linear
def approx_func(x0, y0, t = 'spline'): # t is spline/linear
    assert x0.ndim == 1 and y0.ndim == 1 and x0.size == y0.size#, (x0.shape, y0.shape)
    n = x0.size - 1
    if t == 'linear':
        k = np.diff(y0) / np.diff(x0)
        return piece_wise_linear, (x0, y0, k, np.zeros((0,), dtype = y0.dtype), np.zeros((0,), dtype = y0.dtype))
    elif t == 'spline':
        a, b, c, d = calc_spline_params(x0, y0)
        return piece_wise_spline, (x0, a, b, c, d)
    else:
        assert False, t

# Main function that computes Euclidian Equi-Distant points based on approximation function
@numba.njit(
    [f'f{ii}[:, :](f{ii}[:], f{ii}[:], f{ii}, b1, b1, f{ii}, f{ii}, f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:], f{ii}[:])' for ii in (4, 8)],
    cache = True, fastmath = True)
def _resample_inner(x, y, d, is_spline, strict, aerr, rerr, a0, a1, a2, a3, a4):
    rs, r = 0, np.zeros((1 << 10, 2), dtype = y.dtype)
    t0 = np.zeros((1,), dtype = y.dtype)
    i, x0, y0 = 0, x[0], y[0]
    #print(i, x0, y0, np.sin(x0))
    while True:
        if rs >= r.size:
            r = np.concatenate((r, np.zeros(r.shape, dtype = r.dtype))) # Grow array
        r[rs, 0] = x0
        r[rs, 1] = y0
        rs += 1
        if i + 1 >= x.size:
            break
        ie = min(i + 1 + np.searchsorted(x[i + 1:], x0 + d), x.size - 1)
        for ie in range(i + 1 if strict else ie, ie + 1):
            xl = max(x0, x[ie - 1 if strict else i])
            xr = max(x0, x[ie])
            # Do binary search to find next point
            for ii in range(1000):
                if xr - xl <= aerr:
                    break # Already very small delta X interval
                xm = (xl + xr) / 2
                t0[0] = xm
                if is_spline:
                    ym = piece_wise_spline(t0, a0, a1, a2, a3, a4)[0]
                else:
                    ym = piece_wise_linear(t0, a0, a1, a2, a3, a4)[0]
                
                # Compute Euclidian distance
                dx_, dy_ = xm - x0, ym - y0
                dm = np.sqrt(dx_ * dx_ + dy_ * dy_)

                if -rerr <= dm / d - 1. <= rerr:
                    break # We got d with enough precision
                if dm >= d:
                    xr = xm
                else:
                    xl = xm
            else:
                assert False # To many iterations
            if -rerr <= dm / d - 1. <= rerr:
                break # Next point found
        else:
            break # No next point found, we're finished
        i = np.searchsorted(x, xm) - 1
        #print('_0', i, x0, y0, np.sin(x0), dist(x0, xm, y0, ym), dist(x0, xm, np.sin(x0), np.sin(xm)))
        x0, y0 = xm, ym
        #print('_1', i, x0, y0, np.sin(x0), dm)
    return r[:rs]
    
# Resamples (x, y) points using given approximation function type
# so that euclidian distance between each resampled points equals to "d".
# If strict = True then strictly closest (by X) next point at distance "d"
# is chosen, which can imply more computations, when strict = False then
# any found point with distance "d" is taken as next.
def resample_euclid_equidist(
    x, y, d, *,
    aerr = 2 ** -21, rerr = 2 ** -9, approx = 'spline',
    return_approx = False, strict = True,
):
    assert d > 0, d
    dtype = np.dtype(y.dtype).type
    x, y, d, aerr, rerr = [dtype(e) for e in [x, y, d, aerr, rerr]]
    ixs = np.argsort(x)
    x, y = x[ixs], y[ixs]
    f, fargs = approx_func(x, y, approx)
    r = _resample_inner(x, y, d, approx == 'spline', strict, aerr, rerr, *fargs)
    return (r[:, 0], r[:, 1]) + ((), (lambda x: f(x, *fargs),))[return_approx]

def test():
    import matplotlib.pyplot as plt, numpy as np, time
    np.random.seed(0)
    # Input
    n = 50
    x = np.sort(np.random.uniform(0., 10 * np.pi, (n,)))
    y = np.sin(x) * 5 + np.sin(1 + 2.5 * x) * 3 + np.sin(2 + 0.5 * x) * 2
    # Visualize
    for isl, sl in enumerate(['spline', 'linear']):
        # Compute resampled points
        for i in range(3):
            tb = time.time()
            xa, ya, fa = resample_euclid_equidist(x, y, 1.5, approx = sl, return_approx = True)
            print(sl, 'try', i, 'run time', round(time.time() - tb, 4), 'sec', flush = True)
        # Compute spline/linear approx points
        fax = np.linspace(x[0], x[-1], 1000)
        fay = fa(fax)
        # Plotting
        plt.rcParams['figure.figsize'] = (9.6, 5.4)
        for ci, (cx, cy, fn) in enumerate([
            (x, y, 'original'), (fax, fay, f'approx_{sl}'), (xa, ya, 'euclid_euqidist'),
        ]):
            p, = plt.plot(cx, cy)
            p.set_label(fn)
            if ci >= 2:
                plt.scatter(cx, cy, marker = '.', color = p.get_color())
                if False:
                    # Show distances
                    def dist(x0, x1, y0, y1):
                        # Compute Euclidian distance
                        dx, dy = x1 - x0, y1 - y0
                        return np.sqrt(dx * dx + dy * dy)
                    for i in range(cx.size - 1):
                        plt.annotate(
                            round(dist(cx[i], cx[i + 1], cy[i], cy[i + 1]), 2),
                            (cx[i], cy[i]), fontsize = 'xx-small',
                        )
        plt.gca().set_aspect('equal', adjustable = 'box')
        plt.legend()
        plt.show()
        plt.clf()

if __name__ == '__main__':
    test()

下面是结果图。以函数为例y = np.sin(x) * 5 + np.sin(1 + 2.5 * x) * 3 + np.sin(2 + 0.5 * x) * 2采样于50均匀随机点0 <= x <= 10 * pi范围。地块:blue是原函数,用直线点连接,orange是近似函数(样条函数或线性函数),这只是插值函数,它被绘制为数百个点,这就是为什么看起来平滑,green得到的欧几里德等距离点,正是任务的内容,两个绿色小圆圈之间每段的欧几里德长度恰好等于所需距离d。第一个屏幕表示分段三次样条的近似值。第二个屏幕表示完全相同的输入点的分段线性函数的近似值。

Spline:

spline

Linear:

linear

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

对轨迹进行重新采样,使每个样本中的欧氏距离相等 的相关文章

  • 导入错误:无法导入名称“PandasError”

    我对在 Mac 上运行的 Python 3x 非常陌生 当前使用 python 金融的 senddex 教程 尝试运行以下脚本 import datetime as dt import matplotlib pyplot as plt fr
  • Python 的“platform.mac_ver()”报告不正确的 MacOS 版本

    我正在使用Pythonplatform module https docs python org 3 library platform html要识别 MacOS 版本 如下所示 import platform print platform
  • 每个刻度标签都有不同的颜色

    我正在尝试使用 matplotlib python 3 5 创建一个散点图 其中 x 轴上的每个刻度都有不同的颜色 这怎么可能 例如 假设 x 刻度为 Mo Tu We Th Fr Sa Su 现在我希望 Mo 是绿色的 Tu 是蓝色的 等
  • 使用正则表达式检查整个字符串

    我正在尝试检查字符串是否是数字 因此正则表达式 d 似乎不错 然而 由于某种原因 该正则表达式也适合 78 46 92 168 8000 这是我不想要的 一些代码 class Foo rex re compile d def bar sel
  • 在我的 Mac 上以 root 身份运行 pip 时出现“权限被拒绝”

    我开始使用我的 Mac 来安装 Python 包 就像我在工作中使用 Windows PC 一样 然而在我的 Mac 上我经常遇到没有权限写入日志文件或站点包时出错 于是我想到了跑步pip install
  • 将 pandas 多索引数据帧转换为嵌套字典

    我有一个 pandas 多索引数据框 我试图将其输出为嵌套字典 create the dataset data clump thickness 0 0 274 0 0 1 19 0 1 0 67 0 1 1 12 0 2 0 83 0 2
  • python matplotlib 使用按钮事件添加和删除图形中的文本

    我试图在调用button press event 时将文本添加到鼠标指针位置的图形中 并在调用button release event 时将其删除 我已成功添加文本 但无法将其删除 这是我使用的代码的一部分 def onclick even
  • 有效地写入 pandas 中的多个相邻列

    使用 numpy ndarray 可以一次写入多个列 而无需先进行复制 只要它们相邻 如果我想写入数组的前三列 我会写 a 0 0 3 1 2 3 this is very fast a is a numpy ndarray 我希望在 pa
  • 在Python中将用户昵称转换为正式名字

    我正在尝试根据 Python 中的用户名字和姓氏映射来自不同系统的用户 一个问题是 名字在很多情况下都是 昵称 例如 对于用户来说 他的名字在一个系统中是 Dave 而在另一个系统中是 David python 中有没有简单的方法可以将这些
  • 如何避免在matplotlib中调用latex(输出到pgf)

    我使用 matplotlib 及其 pgf 后端来生成包含在 LaTeX 投影仪文档中的绘图 当我使用未定义的乳胶命令时 我遇到了麻烦 但对于我的应用程序 我不需要 matplotlib 来使用 Latex 生成标签或注释 我只想要正确的
  • 当我移动我的 pygame 角色时,它会留下痕迹[重复]

    这个问题在这里已经有答案了 我一直在尝试用 Python 制作一个游戏 但是当我移动我的角色时 它会留下痕迹 我知道它并没有显示出那么多 但如果你靠近的话 你可以看到这条踪迹 这真的让我很困扰 这是我的代码 import pygame im
  • 检测反射 DLL 注入

    在过去的几年中 恶意软件 以及一些渗透测试工具 如 Metasploit 的 meterpreter 负载 已经开始使用反射 DLL 注入 PDF http www harmonysecurity com files HS P005 Ref
  • Django admin.py 未知命令:'collectstatic'

    我已经从 django 1 2 7 升级到 django 1 5 1我正在使用 python 2 6 6当我尝试跑步时python manage py collectstatic i get 未知命令 collectstatic 从我的设置
  • Python:如何对数组 X 进行排序,但对 Y 进行相同的相对排序?

    例如 X 5 6 2 3 1 Y 7 2 3 4 6 我对X进行排序 X 1 2 3 5 6 但我希望对 Y 应用相同的相对排序 以便数字保持与以前相同的相对位置 Y 6 3 4 7 2 我希望这是有道理的 通常 你会做一个zip sort
  • 使用条件在 pandas 数据框中生成新列

    我有一个 pandas 数据框 如下所示 portion used 0 1 1 0 1 2 0 3 2 3 0 0 3 4 0 8 我想根据以下内容创建一个新专栏used列 以便df看起来像这样 portion used alert 0 1
  • gstreamer 中的无缝视频循环

    我正在尝试使用 gstreamer 循环播放视频 它是 python 绑定 第一次尝试是hook EOSmessage并为管道生成搜索消息 import gi gi require version Gst 1 0 from gi repos
  • 有没有比 Python 内置 == 运算符更快的方法来测试两个列表是否具有完全相同的元素?

    如果我有两个列表 每个列表有 800 个元素长并填充整数 有没有比使用内置元件更快的方法来比较它们具有完全相同的元件 如果没有 则短路 操作员 a 6 2 3 88 54 486 b 6 2 3 88 54 486 a b gt gt gt
  • *Python 内的 Kaggle API 文档?

    我想写一个python从 Kaggle com 下载公共数据集的脚本 Kaggle API 是用 python 编写的 但是我能找到的几乎所有文档和资源都是关于如何在命令行中使用该 API 的 而关于如何使用kaggle图书馆内python
  • matplotlib imshow() 和像素强度

    我试图了解矩阵的值是如何输入到 matplotlib 的imshow 函数确定灰度模式下像素的强度 考虑示例代码 import random import matplotlib pyplot as plt import matplotlib
  • 如何测试send_file烧瓶

    我有一个小型烧瓶应用程序 它需要上传一些图像并将它们转换为多页 tiff 没什么特别的 但是如何测试多个文件的上传和文件下载呢 我的测试客户端 class RestTestCase unittest TestCase def setUp s

随机推荐

  • 在我的应用程序中全局改变滚动条的宽度

    我有一个在触摸屏计算机上运行的 WPF 应用程序 我想将应用程序中的所有滚动条更改得更宽 有没有办法在全球范围内做到这一点 你必须override the default template of scrollViewer增加垂直滚动条的宽度
  • 从 difflib 中获取更细粒度的差异(或者通过后处理差异来实现相同目的的方法)

    正在下载this页面并对其进行较小的编辑 更改第一个65在本段中68 然后我解析两个来源美丽汤并将它们与difflib url https secure ssa gov apps10 reference nsf links 02092016
  • 以 S+(版本 31 及更高版本)为目标需要在存在意图过滤器时定义 android:exported 的显式值]

    在 Android 12 中调试应用程序时 应用程序崩溃了 Android 12 要求您在主要 Activity 中添加一段代码 转到您的项目文件夹并打开 AndroidManifest xml 文件 在活动中添加以下代码 android
  • Rails edit.html.erb 参数错误

    作为 Rails 新手 我浏览了 Hartl 教程并尝试进行一些更改 我想允许用户编辑帖子 我称之为路线 并且当我去编辑路线时收到此错误 else object record is a Array record last record ra
  • 需要使用 get_the_tag_list($ID) WordPress 的帮助

    我正在制作一个新的 WordPress 模板 我只想以文本格式获取与帖子关联的标签列表 我在用 get the tag list id 但问题是它返回 URL 和文本 有没有办法只获取附加到帖子的标签的 文本 并用逗号分隔 i e 标签1
  • 如何在 Bootstrap 中使用间距实用程序类

    In this article我看到了 Bootstrap 4 Spacing Utility Classes 他使用m b lg in className div class row div class col sm 6 m b lg d
  • 具有不同布局的 RecyclerView.ViewHolders 中的 Android DataBinding

    我正在尝试在新项目中使用 androids 数据绑定功能 到目前为止我对此非常满意 但现在我在我的 recyclerviews viewholder 中遇到了一个问题 我的视图持有者使用不同的布局 基于创建时的视图类型 public Med
  • 访问临时内存中用户上传的视频时出现问题

    我正在尝试使用 html 输入类型将用户上传的视频提交到 youtubefile和 python 模块 youtube upload 提交表单后 处理方式如下 if request method POST video request FIL
  • Tensorflow Lite,图像大小零误差

    其实我的问题很简单 我想在tensorflow lite模型中使用我自己的数据 所以 我写了这行代码 root path r C Users 90531 Desktop dataset b image path os path join o
  • 用java抓取一个angularjs网站

    我需要抓取一个由 Angular 插入 内容的网站 而且需要用java来完成 我尝试过 Selenium Webdriver 因为我之前使用过 Selenium 来抓取动态性较低的网页 但我不知道如何处理 Angular 部分 除了页面头部
  • 命名空间命名约定

    对于那些编写可重用组件的人来说 如果要扩展 NET 框架的功能 您认为最佳实践是什么 例如 我目前正在创建一个 Pop3 库 因为 NET 中不存在该库 我是创建自定义命名空间还是使用System Net Mail 来自命名空间命名指南 命
  • 删除Python中每个元素的换行符

    我打开一个文本文件 现在文本文件中的每个元素都用换行符分隔 当我使用readlines 它将这个换行符保留在列表中 这是在每个元素之后 所以它看起来像这样 zebra n ant n 我想知道是否有一个简单的函数或代码片段可以用来删除该换行
  • 安装应用程序后,拖放不再起作用

    我有一个具有拖放功能来导入图像和视频的应用程序 在通过 Visual Studio 进行开发和测试时 从未出现过任何问题 通过设置项目安装后 应用程序中的所有内容都工作正常 除了拖放之外 这似乎什么也没做 是否有任何安全设置需要通过安装程序
  • java:单套接字读写操作。全双工

    我必须实现使用特定源端口发送数据 同时监听该端口 全双工 有谁知道如何在java上实现它 我尝试创建单独的线程来侦听套接字输入流 但它不起作用 我无法将 ServerSocket 和客户端套接字绑定到相同的源端口 并且与 netty 相同
  • 将具有固定大小数组的 C++ 结构编组到 C# 中

    我有一个 C 结构声明如下 public struct AdvertisementData public byte SomeId MarshalAs UnmanagedType LPArray SizeConst 12 public byt
  • 选择每组中的前三个值

    以下是我的示例表和行 create table com company text val int insert into com values com1 1 com1 2 com1 3 com1 4 com1 5 insert into c
  • 如何检查消息是否由特定用户发送discord.py

    我正在使用 Discord py 来制作我的 Discord 机器人 当有人输入消息时 我想检查用户是否是 foo 3645 然后执行某些操作 如果不是 则执行其他操作 if messageAuthor foo 3645 do someth
  • Spring boot 与 H2 数据库自动创建

    我通过 Spring Boot 在我的 Java 应用程序中使用嵌入式 H2 目前 它创建 覆盖 我在数据库中的表 但一旦我把它投入生产 我不希望我的表被擦除并重新创建 所以我不会丢失表中以前的数据 但我不知道如何实现这一点 不知道该放什么
  • 解析动态命名的 JSON 对象最有效的方法是什么?

    我正在尝试解析一个 JSON 响应 其中包含一些我不太熟悉的内容 而且我也没有经常在野外见过 在其中一个 JSON 对象内部 有一个动态命名的 JSON 对象 在这个例子中 里面有一个JSON对象 bugs named 12345 这与错误
  • 对轨迹进行重新采样,使每个样本中的欧氏距离相等

    假设我们有一个 x y 点列表 x 0 0 0 y 0 10 100 点之间的欧几里得距离现在为 10 90 我正在寻找一个接受x y 和sample rate 的函数 并且可以输出相等的距离点 例如 x 0 0 0 y 0 10 100