MATLAB Answers

HB
0

creating a curve from XYZ points (centreline) and then split curve into new points

HB
さんによって質問されました 2019 年 6 月 16 日
最新アクティビティ Image Analyst
さんによって コメントされました 2019 年 6 月 16 日
Hi all,
I have X Y and Z coordinates which represent points along a centreline. There are for instance 60 but I need to be able to change the number of points along the centreline. Therefore I want to load the X Y Z coordinates as a text file, create a curve that precisley follows the points as much as possible and then split this curve into points (such as 100 points).
What is the best way of doing this in MATLAB?
Thanks.

  0 件のコメント

サインイン to comment.

タグ

製品


リリース

R2016b

2 件の回答

回答者: John D'Errico
2019 年 6 月 16 日
編集済み: John D'Errico
2019 年 6 月 16 日

This is a simple problem of interpolation, except that you don't know how to do the interpolation. Standard tools like interp1 don't do it. And interp2 or interp3 are not designed to solve the problem either.
The trick is to use a tool designed to solve that specific problem. (Or to know how to write such a tool. Easier to download the tool itself.) interparc does exactly what you want. Download it from the FEX, here:
interparc can take any set of points that represents a completely general path in 2 or 3 or more dimensions. You tell it how many points to interpolate along the path, and it does so.
x = sort(rand(50,1));
y = sin(3*x);
z = cos(5*x);
xyzi = interparc(100,x,y,z,'spline');
size(xyzi)
ans =
100 3
plot3(x,y,z,'ro')
hold on
plot3(xyzi(:,1),xyzi(:,2),xyzi(:,3),'b-')
box on
grid on
untitled.jpg
So initially, 50 points spaced arbitrarily along a path. Now 100 points, spaced equally in arclength along that curve and smoothly interpolated.

  1 件のコメント

Image Analyst
2019 年 6 月 16 日
Definitely an awesome answer John. +1 vote. Very useful function.
HB, attach your data if you still can't get interparc() to work.

サインイン to comment.


回答者: Matt J
2019 年 6 月 16 日
編集済み: Matt J
2019 年 6 月 16 日

Use a curve fitting function, like lsqcurvefit().

  2 件のコメント

HB
2019 年 6 月 16 日
Thanks. Any ideas about splitting the curve into points?
Matt J
2019 年 6 月 16 日
That part, I didn't understand.

サインイン to comment.



Translated by