
%by mokhtar abbasi. uvinesity of qom
clear
clc
[x,y] = meshgrid(-2:0.2:2,-2:0.2:2);
u=x./(1+x.^2+y.^2);
v=-y./(1+x.^2+y.^2);
quiver(x,y,u,v,'Linewidth',1)
hold on
grid on
t=0:.01:2*pi;

tedad=4;
h(2*tedad)=0;
k=1;
charkhesh(tedad)=0;
mx(tedad)=0;
my(tedad)=0;
for i=1:tedad
    [a,b]=ginput;
    mx(i)=a;
    my(i)=b;
    charkhesh(i)=4*a*b/(1+a^2+b^2)^2;
    xx=.2*cos(t)+a;
    yy=.2*sin(t)+b;
    plot(a,b,'o','MarkerSize',3,'MarkerEdgeColor','k','MarkerFaceColor','c');
    plot(xx,yy,'Linewidth',2)
    text(a-.3,b+.35,num2str(charkhesh(i)))
   h(k)= plot([a,a],[b,.2+b],'k','Linewidth',2);
   k=k+1;
   h(k)=plot(a,.2+b,'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','g');
   k=k+1;
    
    
end
for j=linspace(0,200*pi,400)
    k=1;
    for i=1:4
        delete(h(k));
        h(k)=plot([mx(i),mx(i)+.2*cos(charkhesh(i)*j)],[my(i),.2*sin(charkhesh(i)*j)+my(i)],'k','Linewidth',2);
        k=k+1;
        delete(h(k));
        h(k)=plot(mx(i)+.2*cos(charkhesh(i)*j),.2*sin(charkhesh(i)*j)+my(i),'o','MarkerSize',8,'MarkerEdgeColor','k','MarkerFaceColor','g');
        k=k+1;
    end
    pause(.05)
end

    
    
    
    
