% given 3 vertices a,b,c of a triangle and the angles
% at these vertices find the radius of the sector at
% vertex that is cut off by the the non-degenerate
% central region for the triangle

function out=find_sec_radius(a,b,c,theta_a,theta_b,theta_c)
[a,b,c,theta_a,theta_b,theta_c]
if theta_a>=pi/2
out=0
else
if theta_b>=pi/2
s=abs(a-b)/(1+sin(theta_a));
r=sin(theta_a)*s;
r_ab=abs(a-b)-2*r;
else
r=abs(a-b)/(csc(theta_a)+csc(theta_b));
s_a=r*csc(theta_a);
s_b=r*csc(theta_b);
r_ab=s_a-r;
end % if theta_b >=pi
if theta_c>=pi/2
s=abs(a-c)/(1+sin(theta_a));
r=sin(theta_a)*s;
r_ac=abs(a-c)-2*r;
else
r=abs(a-c)/(csc(theta_a)+csc(theta_c));
s_a=r*csc(theta_a);
s_c=r*csc(theta_c);
r_ac=s_a-r;
end % if theta_c >=pi
out=max(r_ab,r_ac);
end % if theta_a>=pi

return