1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
function arrow(ax,x,y,LW_label,k_arrow)
color0=[0,0,1];
dx=x(1)-x(2);dy=y(1)-y(2);L=sqrt(dx^2+dy^2); if L==0 return; end phi=atan(dy/dx); phi(phi<0)=phi+pi;
arrow_tan=100/333; x_arrow=-[0,1,1]*k_arrow; y_arrow=[0,arrow_tan,-arrow_tan]*k_arrow; rotmat=[cos(phi),-sin(phi);sin(phi),cos(phi)]; temp=rotmat*[x_arrow;y_arrow]; x_arrow_R=temp(1,:);x_arrow_L=-x_arrow_R; y_arrow_R=temp(2,:);y_arrow_L=-y_arrow_R;
line(ax,x,y,'LineWidth',LW_label,'Color',color0);
if y(1)>y(2) || (y(1)==y(2) && x(1)>x(2)) patch(ax,'XData',x(1)+x_arrow_R,'YData',y(1)+y_arrow_R,'FaceColor',color0,'EdgeColor',color0); patch(ax,'XData',x(2)+x_arrow_L,'YData',y(2)+y_arrow_L,'FaceColor',color0,'EdgeColor',color0); else patch(ax,'XData',x(2)+x_arrow_R,'YData',y(2)+y_arrow_R,'FaceColor',color0,'EdgeColor',color0); patch(ax,'XData',x(1)+x_arrow_L,'YData',y(1)+y_arrow_L,'FaceColor',color0,'EdgeColor',color0); end
end
|