function vector = draw_arrow_2d ... ... (x1,y1,dx,dy) %-------------------------------------- % Generate coordinates for plotting % a five-point arrow starting at the point % (x1,x2) and ending at the point (x1+dx, y1+dy) % % SYMBOLS: % -------- % % dx, dy: arrow vector % % vector(i,1): x-coordinate of the ith point % vector(i,2): y-coordinate of the ith point % where i=1,2,3,4,5 % % angle: angle of arrow tip in radians % % tip: length of arrow tip sides % as a fraction of the arrow length %--------------------------------------- angle=0.3; tip=0.50; %-------- % prepare %-------- x2 = x1+dx; y2 = y1+dy; cs = cos(angle); sn = sin(angle); dxi = -dx; dyi = -dy; %------------ % first point %------------ vector(1,1) = x1; vector(1,2) = y1; %--- % second point %--- vector(2,1) = x2; vector(2,2) = y2; %--- % third point %--- vector(3,1) = x2+( dxi*cs+dyi*sn)*tip; vector(3,2) = y2+(-dxi*sn+dyi*cs)*tip; %--- % fourth point %--- vector(4,1) = x2; vector(4,2) = y2; %--- % fifth point %--- vector(5,1) = x2+(dxi*cs-dyi*sn)*tip; vector(5,2) = y2+(dxi*sn+dyi*cs)*tip; %----- % done %----- return