fprintf(['\n' ... 'Geben Sie zunaechst die Ordnung n ein.\n\n' ... 'Klicken Sie dann mit der Maus ein\n'... 'Kontrollpolygon mit n Punkten an.\n'... '\n'... 'Um einen Punkt zu verschieben, klicken Sie auf \n'... 'diesen und bewegen ihn dann mit der Maus.\n'... 'Ein weiterer Klick fixiert den Punkt wieder.\n'... '\n'... 'Ein Klick ausserhalb der Einheitsquadrats beendet das Programm.\n\n']) clear co = inline('[sx(1), sy(1)] + [sx(2), sy(2)].*get(0,''PointerLocation'')','sx','sy'); n = input('Ordnung = '); m = n; h1 = pi; h2 = pi; T = [zeros(1,n) ones(1,n)]; figure(1) clf reset hold on set(gca,'FontSize',17) a = [0 1 0 1]; axis(a) set(1,'Doublebuffer','on') set(1,'Windowbuttondownfcn','stop = 1;') for i=1:n [px(i),py(i)] = ginput(1); z = get(0,'PointerLocation'); X(i) = z(1); Y(i) = z(2); if ishandle(h1) delete(h1); end if ishandle(h2) delete(h2); end h1 = plot(px,py,'LineWidth',3); h2 = plot(px,py,'.','MarkerSize',35); end qx = (px(2)-px(1))/(X(2) - X(1)); qy = (py(2)-py(1))/(Y(2) - Y(1)); sx = [px(1) - qx*X(1), qx]; sy = [py(1) - qy*Y(1), qy]; T = linspace(0,1,m); E = eye(m); A = zeros(m,50); for k=1:m pol = polyfit(T,E(k,:),n); A(k,:) = polyval(pol,linspace(0,1,50)); end %A = seval(eye(m),T,linspace(min(T),max(T),50)); delete(h1); delete(h2); h1= plot(px,py,'LineWidth',3); h2= plot(px,py,'.','MarkerSize',35); h3= plot(px*A,py*A,'r','LineWidth',3); while 1 waitforbuttonpress %[x,y] = coord(sx,sy); xy = co(sx,sy); x = xy(1); y = xy(2); if x<0 close(1) return end d = abs(px - x) + abs(py - y); [m,i] = min(d); stop = 0; while ~stop %[x,y] = coord(sx,sy); xy = co(sx,sy); x = xy(1); y = xy(2); px(i) = x; py(i) = y; set(h1,'XData',px,'YData',py) set(h2,'XData',px,'YData',py) set(h3,'XData',px*A,'YData',py*A) axis(a) drawnow end end