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
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
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 + y12 x1 y1 1 x22 + y22 x2 y2 1 x32 + y32 x3 y3 1 = 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:
This can be converted to the canonical form of the equation of a circle:(x2 + y2)·M11 - x·M12 + y·M13 - M14 = 0
Completing the squares in x and y gives:x2 + y2 - (M12/M11)·x + (M13/M11)·y - M14/M11 = 0
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