3D line approximation (spline)

Hi everyone,
How can we use "spline" to approximate a sequence of points in three dimension rather than interpolate?

2 件のコメント

Hongying LI
Hongying LI 2011 年 2 月 21 日
I do look for a "approximation" method for a line in "3D".(I have done the interpolation)
Hongying LI
Hongying LI 2011 年 2 月 22 日
% choose the number of pieces
pieces = 3;
s = cumsum([0;sqrt(diff(x(:)).^2 + diff(y(:)).^2 + diff(z(:)).^2)]);
pp1 = splinefit(s,xyz,pieces);
xyz1 = ppval(pp1,s);

サインインしてコメントする。

回答 (1 件)

Bruno Luong
Bruno Luong 2011 年 2 月 21 日

3 投票

4 件のコメント

Hongying LI
Hongying LI 2011 年 2 月 21 日
Maybe you mean that I should learn from these and write one myself ? (as I think that these files can not be used directly to approximate a 3D line)
Bruno Luong
Bruno Luong 2011 年 2 月 21 日
No. I do not mean that. A 3D line are simply three independent functions parametrized by an independent variables (called t for example).
All you need is interpolate (xi,yi,zi) by
xi = f(ti)
yi = g(ti)
zi = h(ti)
I recommend select {ti} as the cumulative sum of the euclidian distance of the data.
Hongying LI
Hongying LI 2011 年 2 月 21 日
Thanks Bruno,
This is my previous codes:
function newCurve = spline3dCurveInterpolation(curve, dt)
% interpote a 3d curve using spline
% path 3*x
% newPath 3*x
x = curve(1, :);
y = curve(2, :);
z = curve(3, :);
t = cumsum([0;sqrt(diff(x(:)).^2 + diff(y(:)).^2 + diff(z(:)).^2)]);
sx = spline(t,x);
sy = spline(t,y);
sz = spline(t,z);
tt = t(1):dt:t(end);
xp = ppval(sx, tt);
yp = ppval(sy, tt);
zp = ppval(sz, tt);
newCurve = [xp; yp; zp];
% end of function
Now, I'm thinking about the approximation and I don't want the line strictly pass the original points.(maybe I still don't understand your answer)
Bruno Luong
Bruno Luong 2011 年 2 月 21 日
Did you try the FEX file (try the first one) above? They are approximation (fitting) not interpolation, exactly as your request if I'm not mistaken.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSpline Postprocessing についてさらに検索

質問済み:

2011 年 2 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by