function bisection2()
#=================================

# image K of citcle  C(rr, x0, y0)

nn=1000;
rr=5;
rr=input("rr=");
x0=input('x0=');
y0=input('y0=');
ang=2*pi/nn

vectu=[1:nn];
vectv=[1:nn];

for i = 1:nn
  x=x0+rr*cos(ang*i);
  y=y0+rr*sin(ang*i);
  uu=ff(x,y);
  vv=gg(x,y);
  vectu(i) = uu;
  vectv(i) = vv;
endfor

wnum=windnumber(nn, vectu, vectv, x0, y0);
disp('wnum=');  disp(wnum);

plot(vectu,vectv)
  
end

#=========================================================================
function ret=ff(x,y)
  ret=x*x-y*y;
  #ret=sin(x+y);
end

#=========================================================================
function ret=gg(x,y)
  ret=x*y-1;
  #ret=sin(x+y);
end

#=========================================================================
function wnum=windnumber(n, curvex, curvey, ptx, pty)
  wnum=0;
  
  for i =1:(n-1)
    fi = 0; #angle
    p1=curvex(i)*curvey(i+1) - curvex(i+1)*curvey(i);
    p2=curvex(i)*curvex(i+1) + curvey(i)*curvey(i+1);
    fi = atan2(p1, p2);
    wnum = wnum + fi;
  endfor
  
  wnum= wnum/2/3.14159;
end

#=========================================================================
#  how  to  use
function wn=wnum(nn, R, x0, y0)
  wn=0
  ang= 2*3.15/float(nn)
  #print("angle step=", ang)
  uff=[1:nn];
  vgg=[1:nn];
  for i =1:(nn)
    x=x0+R*math.cos(ang*i)
    y=y0+R*math.sin(ang*i)
    uu=ff(x,y)
    vv=gg(x,y)
    uff(i)=uu
    vgg(i)=vv
  endfor

  wn = windnumber(nn, uff, vgg, x0, y0)
  
end
#{
#=========================================================================
#function curveplot(nn, rr, x0, y0)
  
#end
#}