Average ratio of incenters to circumcenters, using matlab

Alec Jacobson

February 08, 2010

weblog/

The incenter radius of a triangle is given by the formula:
      2*A      with A = area
r = -------
    (a+b+c)  


the circumcenter radius is given by
     abc
R = -----
     (4A)
We want the ratio of the incenter to circumcenter so that's
r         8A2
_ = ---------------
R   ((a+b+c)*(abc))
So then if you have a triangle mesh with a variable edge_norms which is an n by 3 matrix of the lengths of edges in your mesh, a way to get the incenter radii is, first applying Heron's formula to find the areas of each triangle:
semi_perimeters = (edge_norms(:,1) + edge_norms(:,2) + edge_norms(:,3))*0.5;
areas = sqrt( ...
  semi_perimeters.* ...
  (semi_perimeters-edge_norms(:,1)).* ...
  (semi_perimeters-edge_norms(:,2)).* ...
  (semi_perimeters-edge_norms(:,3)));
ratios = 8*areas.*areas./(sum(edge_norms')'.*prod(edge_norms')')
Then just take the mean:
mean(ratios)
Note: I coded up the calculations of the incenters and circumcenters to check this out so I figure I might as well post that, too:
r=2*areas./(edge_norms(:,1)+edge_norms(:,2)+edge_norms(:,3))
R=(edge_norms(:,1).*edge_norms(:,2).*edge_norms(:,3))./(4*areas)