clc
clf
clear

S = [-1 1 1+sqrt(2) 1+sqrt(2) 1.0 -1.0 -1*(1+sqrt(2)) -1.0*(1+sqrt(2))
     -1*(1+sqrt(2)) -1*(1+sqrt(2)) -1 1 1+sqrt(2) 1 + sqrt(2) 1 -1];
M =[1/2 0; 0 -1/2];
v = [3;4];
connect_dots(S,6);
hold on
connect_dots(M*S,6);
connect_dots(M*S+v,6);

%plot 2 original coords
plot(1.0,1+sqrt(2),'kd','MarkerSize',10);
plot(1+sqrt(2),1,'k*','MarkerSize',10);
%transformed pointsp1 = M*[1.0;1+sqrt(2)] +v;
p1 = M*[1.0;1+sqrt(2)];
p2 = M*[1+sqrt(2);1];

plot(p1(1),p1(2),'kd','MarkerSize',10);
plot(p2(1),p2(2),'k*','MarkerSize',10);
p1 = M*[1.0;1+sqrt(2)] +v;
p2 = M*[1+sqrt(2);1]+v;
plot(p1(1),p1(2),'kd','MarkerSize',10);
plot(p2(1),p2(2),'k*','MarkerSize',10);
title('Affine Transformations')
yline(0,'--');
hold off
