Rigidly translating and mirroring 2D coordinates
Afficher commentaires plus anciens
Hi! I would like to rigidly translate the coordinates of file curve2.txt so that its center of gravity coincides with the center of gravity of file curve1.txt. I tried to use the command "transltform2d" but it gives me an error.
curve1 = importdata("curve1.txt");
x_curve1 = sum(curve1(:,1))/length(curve1(:,1));
y_curve1 = sum(curve1(:,2))/length(curve1(:,2));
G_curve1 = [x_curve1, y_curve1];
curve2 = importdata("curve2.txt");
x_curve2 = sum(curve2(:,1))/length(curve2(:,1));
y_curve2 = sum(curve2(:,2))/length(curve2(:,2));
G_curve2 = [x_curve2, y_curve2];
tx = G_curve2 - G_curve1;
ty = G_curve2 - G_curve1;
tform = transltform2d(tx, ty);
figure
plot(curve1(:,1),curve1(:,2),'k.', 'MarkerSize', 10)
hold on
plot(G_curve1(:,1),G_curve1(:,2),'k.', 'MarkerSize', 15)
plot(curve2(:,1),curve2(:,2),'r.', 'MarkerSize', 10)
plot(G_curve2(:,1),G_curve2(:,2),'r.', 'MarkerSize', 15)
hold off
grid off
axis equal
xlabel('x')
ylabel('y')
And then I should mirror, with respect to the Y axis, curve2.txt with respect to its center of gravity.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
