% given N points and a triangulation of these points
% find the radius of the sector associated to each vertex
% of each triangle
function radii=find_radii(x,y,tri)
N=size(tri,1);
radii=zeros(N,3);
for n=1:N
a=x(tri(n,1))+i*y(tri(n,1));
b=x(tri(n,2))+i*y(tri(n,2));
c=x(tri(n,3))+i*y(tri(n,3));
theta_a=abs(imag(log( (b-a)/(c-a) ) )/2);
theta_b=abs(imag(log( (a-b)/(c-b) ) )/2);
theta_c=abs(imag(log( (a-c)/(b-c) ) )/2);
2*(theta_a+theta_b+theta_c);
rad_a=cos(theta_a)*abs(a-c)*sin(theta_c)...
/sin(pi-theta_a-theta_c);
rad_b=cos(theta_b)*abs(b-a)*sin(theta_a)...
/sin(pi-theta_b-theta_a);
rad_c=cos(theta_c)*abs(c-b)*sin(theta_b)...
/sin(pi-theta_c-theta_b);
rad_a+rad_b-abs(a-b);
rad_b+rad_c-abs(b-c);
rad_a+rad_c-abs(a-c);
radii(n,1)=rad_a;
radii(n,2)=rad_b;
radii(n,3)=rad_c;

% draw inscribed circle
%dist_a=abs(a-c)*sin(theta_c)/sin(pi-theta_a-theta_c);
%angle=imag(log(c-a))+ imag(log((b-a)/(c-a) ))/2;
%r=sin(theta_a)*dist_a;
%center=a+dist_a*exp(i*angle);
%z=center+r*exp(2*pi*i*[0:.02:1]);
%plot(real(z),imag(z),'c')

% draw circular arc connecting tangent points
%plot_prop_arc(a,b,c,rad_a)
%plot_prop_arc(b,a,c,rad_b)
%plot_prop_arc(c,a,b,rad_c)

end % for n
return