close all;
clear all;
% a 2D pologyon
p=[-1 1 1 -1 -1 ; -1 -1 1 1 -1];
% points p = in homogeneous coord
p(3,:)=1;
% axes for plotting the animation
figure;
hold on;
axis([-6 6 -6 6]);
axis equal;
for theta=0:0.005:2*pi
R=[cos(theta) -sin(theta) 0 ; sin(theta) cos(theta) 0 ; 0 0 1];
pdash=R*p;
pdash(1,:)=pdash(1,:)./pdash(3,:);
pdash(2,:)=pdash(2,:)./pdash(3,:);
cla;
plot(pdash(1,:),pdash(2,:),'b');
drawnow;
end
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Here you are the modified code:
You can learn more here:
Transforming Objects - MATLAB
Open in new window