# Circle containing three points, maybe all collinear

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?

• "when at least two of the are collinear"? Two points are always collinear, three points are always coplanar. The exceptional case is when all three points are collinear (which includes as special case that some points may coincide) – Hagen von Eitzen Dec 2 '13 at 21:44
• I'm afraid the use of the word collinear in "two points of them are collinear to each other (two of them have same x- logic or y-coordinates)" is utter gibberish. – Will Jagy Dec 2 '13 at 21:44
• It is, and I apologize. Hope it is now better. – reindeer Dec 2 '13 at 21:47

## 1 Answer

Hint: If the three points are colinear, they are in order on a line. If one of them has to be inside the circle, which one is it? Do you know the construction to find the circle if they are not colinear?

• If the line is parallel to x-axis, its the one with the median x value, if its parallel to y-axis, its the one with the median y-value. Yes, I totally had a brain lag when asking this question. I already have the version with three non-collinear points, but get an error state when they are. – reindeer Dec 2 '13 at 21:55
• Better said: if it is not parallel to the $x$ axis, it is the one with median $y$ value. You can always use one median or the other to find the central point. – Ross Millikan Dec 2 '13 at 21:58