% Matlab program to test the accuracy of Graph Reader
clf;

basis1 = rand(1,2)-0.5;
basis2 = rand(1,2)-0.5;

plot (0, 0, '.');
hold on;

anchor1 = rand(1,2)-0.5;
s1 = sprintf ('%f %f', anchor1(1), anchor1(2));
screen_anchor1 = anchor1(1)*basis1 + anchor1(2)*basis2;
plot (screen_anchor1(1), screen_anchor1(2), 'o');

anchor2 = rand(1,2)-0.5;
s2 = sprintf ('%f %f', anchor2(1), anchor2(2));
screen_anchor2 = anchor2(1)*basis1 + anchor2(2)*basis2;
plot (screen_anchor2(1), screen_anchor2(2), '^');

anchor3 = rand(1,2)-0.5;
s3 = sprintf ('%f %f', anchor3(1), anchor3(2));
screen_anchor3 = anchor3(1)*basis1 + anchor3(2)*basis2;
plot (screen_anchor3(1), screen_anchor3(2), 's');

testp = rand(1,2)-0.5;
s4 = sprintf ('%f %f', testp(1), testp(2));
screen_testp = testp(1)*basis1 + testp(2)*basis2;
h = plot (screen_testp(1), screen_testp(2), '*');
set (h, 'Color', [0.8 0.2 0.2]);

arrow ([0,0], basis1/2, 0.5);
arrow ([0,0], basis2/2, 0.5);

legend ('0 0', s1, s2, s3, s4);

title ('Graph Reader Tester');
xlabel ('X'); ylabel ('Y');

