What is the algorithm for finding the center of a circle from three points?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In computational geometry, determining the center of a circle that passes through three given non-collinear points is a fundamental problem. It appears in computer graphics, geographic information systems, robotics, and mesh generation. The solution uses the concept of perpendicular bisectors: the center of the circle (circumcenter) lies at the intersection of the perpendicular bisectors of any two sides of the triangle formed by the three points.
Conceptual Overview
Given three non-collinear points , , and , these points define a unique circle called the circumcircle. The center of this circle, the circumcenter, is equidistant from all three points. The key geometric property is that the perpendicular bisector of a chord always passes through the center of the circle, so the intersection of any two perpendicular bisectors gives us the circumcenter.
Algorithm Steps
- Calculate midpoints of two sides of the triangle.
- Determine slopes of those two sides.
- Compute perpendicular slopes (negative reciprocal of each side's slope).
- Write equations of the perpendicular bisectors using point-slope form.
- Solve the system of two linear equations to find the intersection point (the circumcenter).
Step-by-Step Example
Given points: , , .
Step 1: Midpoints
The midpoint formula is:
- Midpoint of :
- Midpoint of :
Step 2: Slopes of the Sides
The slope formula is:
- Slope of :
- Slope of :
Step 3: Perpendicular Slopes
The perpendicular slope is the negative reciprocal:
- Perpendicular to :
- Perpendicular to :
Step 4: Equations of Perpendicular Bisectors
Using point-slope form :
Bisector of through :
Bisector of through :
Step 5: Solve for Intersection
Setting the two equations equal:
Multiply through by 40 to clear fractions:
Substituting back:
The circumcenter is at approximately .
Direct Formula (Determinant Method)
For implementation, a more robust approach avoids slope calculations (which fail for vertical lines) by solving the system directly. The circumcenter satisfies:
Expanding and rearranging yields a linear system that can be solved with:
This method is numerically stable and handles all non-degenerate cases.
Key Formulas Summary
| Step | Formula |
| Midpoint | |
| Slope | |
| Perpendicular slope | |
| Point-slope line | |
| Circumcenter | Intersection of two perpendicular bisectors |
Edge Cases
- Collinear points: If all three points lie on a straight line, no unique circle exists. The determinant in the formula above will be zero (or near zero). Your implementation should detect this and handle it as an error.
- Vertical or horizontal sides: The slope-based approach fails when a side is vertical (undefined slope). The determinant method avoids this problem entirely.
- Nearly collinear points: When points are close to collinear, the circumradius becomes very large and numerical precision suffers. Consider using higher-precision arithmetic for such cases.
Summary
Finding the center of a circle through three points reduces to finding the intersection of two perpendicular bisectors. While the geometric approach (midpoints, slopes, bisectors) is intuitive, the determinant-based formula is more robust for implementation since it avoids division-by-zero issues with vertical lines. The algorithm runs in time and is a building block for larger geometric algorithms like Delaunay triangulation and Voronoi diagrams.

