# Find maximum angle in a triangle mesh, using matlab

## Alec Jacobson

## February 08, 2010

If a,b,c are the lengths of the side of a triangle then the maximum angle of the triangle is the angle opposite the largest side, call that one c. A formula for this angle is then
` / a`^{2} + b^{2} - c^{2} \
cos^{-1}| ------------ |
\ 2*a*b /

So then if you have a variable `edge_norms`

which is an n by 3 matrix of the lengths of edges in your mesh, a way to find the maximum angle of each face is to issue:
```
acos(((sum(edge_norms'.^2)-2*max(edge_norms').^2)) ...
./(2*prod(edge_norms')./max(edge_norms')))
```

I like to make mine in degrees by adding
```
(...)./(2*pi).*360
```

And then you can find the maximum angle over all by issuing
`max(...)`

Surely this can be optimized, but I think matlab does a fair job on its own at that already.