We all know that a circle is exactly defined by three distinct non-collinear points. But I need a way to solve the following problem (all in 2D):
Given three points, calculate a circle with all three points on its border if it exists, else calculate a circle with minimum radius which has two points on its border, and containing the third. The latter should happen when the three points are collinear.
I tried to draw all cases that can exist, but I do not come up with something elegant as a solution. Has somebody an easy way for it?