
Improving the interpolation of nodes arranged in a circle on a plane
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?

0 commentaires
Réponse acceptée
Matt J
le 17 Jan 2024
Modifié(e) : Matt J
le 17 Jan 2024
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

0 commentaires
Plus de réponses (1)
Mathieu NOE
le 17 Jan 2024
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 commentaires
Mathieu NOE
le 18 Jan 2024
hello again
node_interp = [x(:) y(:) z(:)];
plot3(node_interp(:,1), node_interp(:,2), node_interp(:,3), 'r.', 'Markersize', 15);
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!