How to plot points from a geometric transformation matrix?
Afficher commentaires plus anciens
In the following code I need to change the plot function code every time the number of vertices change. Is there a function which can plot any number of vertices?
clc
clear
n=input('Enter the number of vertices')
for i=1:n
x(i)=input('Enter the x coordinate');
y(i)=input('Enter the y coordinate');
end
a=[x;y;ones(1,n)]
ro=[-1 0 0;0 -1 0;0 0 1];
disp('The final Matrix is')
c=ro*a
grid on
hold on
X1=[a(1,1),a(1,2),a(1,3),a(1,4),a(1,1)];
Y1=[a(2,1),a(2,2),a(2,3),a(2,4),a(2,1)];
plot(X1,Y1,'g')
fill(X1,Y1,'g')
X2=[c(1,1),c(1,2),c(1,3),c(1,4),c(1,1)];
Y2=[c(2,1),c(2,2),c(2,3),c(2,4),c(2,1)];
plot(X2,Y2,'r')
fill(X2,Y2,'r')
hold off
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Labels and Annotations 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!