| home | contents | send comment | send link | add bookmark |

Circle Solver

by Stephen R. Schmitt

Enter three points {x, y}:
x y
Center and radius:
Xo =
Yo =
radius =

Contents

  1. About
  2. The source code
  3. Discussion

1. About

This Java Script calculator finds the center and radius of a circle given three points on the Cartesian plane. To operate the calculator, enter the x-y coordinates for three points. Press the Compute button to obtain the solution. On invalid entries, a popup window will display an error message.

Return to Contents


2. The source code

The Java Script source code for this program can be viewed by using the View|Source command of your web browser.

You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitability of this source code for your use.

Return to Contents


3. Discussion

From analytic geometry, we know that there is a unique circle that passes through three points if, and only if, they are not on the same line. Given three points,

{x1, y1}, {x2, y2}, {x3, y3}
how does one find the center and radius of a circle fitting those points? They can be found by solving the following determinant equation:
x2 + y2 x y 1
x12 + y12x1y11
x22 + y22x2y21
x32 + y32x3y31
= 0

Evaluating the cofactors for the first row of the determinant can give us a solution. The determinant equation can be written as an equation of these cofactors:

(x2 + y2)·M11 - x·M12 + y·M13 - M14 = 0
This can be converted to the canonical form of the equation of a circle:
x2 + y2 - (M12/M11)·x + (M13/M11)·y - M14/M11 = 0
Completing the squares in x and y gives:
x0 =  0.5·M12/M11 
y0 = -0.5·M13/M11 
r02 = x02 + y02 + M14/M11 

Note that there is no solution when M11 is equal to zero. In this case, the points are not on a circle.

Return to Contents



Copyright © 2004, Stephen R. Schmitt