重新采样或插入不均匀间隔的路径

时间:2015-07-14 10:34:29

标签: matlab interpolation resampling

假设我有一条由3D点组成的路径,其中连续点之间的距离不是恒定的。

如何重新取样使连续点之间的距离变得恒定?

我试着调查interp1,但我不知道假设参数化曲线x(t),y(t),z(t)的原始查询点。

示例路径:

enter image description here

1 个答案:

答案 0 :(得分:7)

您可以使用 Matlab文件交换中的interparc。在以下示例中,此函数计算原始曲线的100个等间距点。默认情况下,使用样条插值并提供平滑曲线。通过定义可选参数,我们可以更改此行为。使用'linear'进行线性近似(效率最高)。

以下是代码:

% define some original points
A = [0.132488479262673 0.427113702623907;0.160138248847926 0.462099125364431;0.197004608294931 0.532069970845481;0.236175115207373 0.634110787172012;0.263824884792627 0.677842565597668;0.284562211981567 0.709912536443149;0.307603686635945 0.744897959183673;0.339861751152074 0.785714285714286;0.376728110599078 0.806122448979592;0.40668202764977 0.814868804664723;0.452764976958525 0.817784256559767;0.498847926267281 0.82069970845481;0.521889400921659 0.82069970845481;0.542626728110599 0.82069970845481;0.561059907834101 0.817784256559767;0.579493087557604 0.806122448979592;0.639400921658986 0.759475218658892;0.669354838709677 0.721574344023324;0.713133640552995 0.654518950437318;0.752304147465438 0.581632653061224;0.784562211981567 0.485422740524781;0.793778801843318 0.412536443148688;0.784562211981567 0.316326530612245;0.773041474654378 0.284256559766764;0.754608294930876 0.260932944606414;0.722350230414747 0.231778425655977;0.660138248847926 0.214285714285714;0.567972350230415 0.188046647230321];

% plot original
figure
plot(A(:,1),A(:,2),'*-')

% interpolate
B = interparc(100,A(:,1),A(:,2));             % spline
%B = interparc(100,A(:,1),A(:,2),'linear');   % linear

% plot interpolated
figure
plot(B(:,1),B(:,2),'*-')

结果如下: result1_1 result1_2