The only thing that needed care was which sign of the sqrt bisects the internal angle as opposed to the external angle.
In general I prefer not to deal with angles when dealing with 2D rotation. Get inputs in angles if need be and from then onwards use the (cos,sin) tuple or, equivalently, use complex numbers. One can get rid of calls to trascendentals as long as you are happy to call sqrt.
In other words angle is a tuple.
The same calculation works in R^n, incidentally, using the geometric product. This is pretty much the ideal usecase for it, for constructing operators between vectors.
https://news.ycombinator.com/item?id=48619191
You probably know this, but this is one way to generalize beyond 2D