Improving the interpolation of nodes arranged in a circle on a plane

1 回表示 (過去 30 日間)
Alberto Acri
Alberto Acri 2024 年 1 月 17 日
コメント済み: Mathieu NOE 2024 年 1 月 18 日
I am using this code to improve the interpolation of nodes arranged in a circle on a plane.
As input I have the nodes 'outermost_nodes_sel'.
outermost_nodes_sel = importdata("outermost_nodes_sel.txt");
figure
plot3(outermost_nodes_sel(:,1), outermost_nodes_sel(:,2), outermost_nodes_sel(:,3), 'r.', 'Markersize', 15);
hold off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
% Interpolation
Nt = size(outermost_nodes_sel,1);
t = 1:Nt;
t_new = linspace(1,Nt,3*Nt-1);
line_new = interp1(t,outermost_nodes_sel,t_new);
figure
plot3(line_new(:,1), line_new(:,2), line_new(:,3), 'r.', 'Markersize', 15);
hold off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
It generates this space for me. How do I insert nodes there too?
Also, is it possible to keep the coordinates of the nodes 'outermost_nodes_sel' fixed?

採用された回答

Matt J
Matt J 2024 年 1 月 17 日
編集済み: Matt J 2024 年 1 月 17 日
You could fit a circle to the given points and then resample it using this FEX download,
load('outermost_nodes_sel.mat')
P=planarFit(outermost_nodes_sel');
xy0=P.project2D(outermost_nodes_sel'); %Map measured 3D samples to 2D
c=circularFit(xy0); %Perform circular fit in 2D
XYZ=P.unproject3D( cell2mat(c.sample(0:5:360)) ); %Post-sample the ellipse fit and map back to 3D
%%Visualize
hold on
scatter3(outermost_nodes_sel(:,1) , outermost_nodes_sel(:,2), outermost_nodes_sel(:,3),...
'b','filled','SizeData',100);
scatter3(XYZ(1,:), XYZ(2,:), XYZ(3,:),'r','filled');
grid on
view(3)
legend Original Interpolated
hold off

その他の回答 (1 件)

Mathieu NOE
Mathieu NOE 2024 年 1 月 17 日
hello Alberto
try this - I think it's easier once you work in polar coordinates.
I am not sure to understand by "is it possible to keep the coordinates of the nodes 'outermost_nodes_sel' fixed?" ?
you can overlay both sets of data - this will do nothing to the values of outermost_nodes_sel array
% outermost_nodes_sel = importdata("outermost_nodes_sel.txt");
load("outermost_nodes_sel.mat");
figure
plot3(outermost_nodes_sel(:,1), outermost_nodes_sel(:,2), outermost_nodes_sel(:,3), 'r.', 'Markersize', 15);
hold off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
[TH,R,Z] = cart2pol(outermost_nodes_sel(:,1), outermost_nodes_sel(:,2), outermost_nodes_sel(:,3));
% Interpolation
Nt = size(outermost_nodes_sel,1);
t = 1:Nt;
TH_new = linspace(min(TH),min(TH)+2*pi,3*Nt-1); % make sure the range is 2*pi
line_new = interp1(TH,[R Z],TH_new);
[x,y,z] = pol2cart(TH_new, line_new(:,1), line_new(:,2));
figure
plot3(x, y, z, 'r.', 'Markersize', 15);
hold off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
  2 件のコメント
Alberto Acri
Alberto Acri 2024 年 1 月 17 日
Thank you for your answer! How can I create a rowsx3 matrix of those nodes you see with this line of code?
plot3(x, y, z, 'r.', 'Markersize', 15);
I would like to reproduce it like this:
plot3(node_interp(:,1), node_interp(:,2), node_interp(:,3), 'r.', 'Markersize', 15);
Thanks!
Mathieu NOE
Mathieu NOE 2024 年 1 月 18 日
hello again
node_interp = [x(:) y(:) z(:)];
plot3(node_interp(:,1), node_interp(:,2), node_interp(:,3), 'r.', 'Markersize', 15);

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

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by