Primary change: fixing up calculation of opening and closing angles.
I'm pretty sure they work as advertised now.

Secondary change: fixing a lot of indents and line wraps to make
the code more readable in normal editors.  No structure changes there.