相关疑难解决方法(0)

任意轮廓的平滑样条表示,f(长度) - > x,y

假设我有一组x,y坐标,用于标记沿轮廓的点.有没有办法可以构建轮廓的样条曲线表示,我可以在其长度上的特定位置进行求值并恢复插值的x,y坐标?

通常情况下,X和Y值之间没有1:1的对应关系,因此单变量样条对我没有好处.双变量样条曲线很好,但据我所知,所有用于评估二元样条函数的函数都scipy.interpolate取x,y值并返回z,而我需要给出z并返回x,y(因为x,y是点上的一行,每个z映射到唯一的x,y).

这是我希望能够做到的草图:

import numpy as np
from matplotlib.pyplot import plot

# x,y coordinates of contour points, not monotonically increasing
x = np.array([ 2.,  1.,  1.,  2.,  2.,  4.,  4.,  3.])
y = np.array([ 1.,  2.,  3.,  4.,  2.,  3.,  2.,  1.])

# f: X --> Y might not be a 1:1 correspondence
plot(x,y,'-o')

# get the cumulative distance along the contour
dist = [0]
for ii in xrange(x.size-1):
    dist.append(np.sqrt((x[ii+1]-x[ii])**2 + (y[ii+1]-y[ii])**2))
d = np.array(dist)

# build a …
Run Code Online (Sandbox Code Playgroud)

bezier numpy spline curve-fitting scipy

13
推荐指数
2
解决办法
9979
查看次数

标签 统计

bezier ×1

curve-fitting ×1

numpy ×1

scipy ×1

spline ×1