Printing general equation of circle by C programming

Given x,y coordinates of 3 points, I have to tell that is it possible to draw a circle. If so, what is the equation of the circle in this format:
x^2 + y^2 + 2gx + 2fy + c = 0

Note that I am programming in C.
Help me.

  1. Check if the three points are co-linear. If they are, then it is clearly not possible to draw the circle, and your program ends.
  2. If they are not co-linear, then note that in the above equation, (-g, -h) represent the center of the circle. You can verify this by expanding (x - g)^{2} + (y - h)^{2} = r^{2}. (a circle centered at (g, h) with radius h) and comparing the equation with the one you gave.
  3. Also, it can be noted that c=g^2 + h^2 - r^2.
  4. Now, use the equations given at Cartesian coordinates for circumcenter of a triangle to determine the x and y coordinates of the center, and also to determine the diameter, and hence radius of the circle. For convenience, here they are:
    Equations for center
    Equations for center
    Equations for center
  5. It then remains to plug in the values in your equation as:

g = -U_x
h = -U_y
c = g^2 + h^2 - r^2 where
r = D/2

thanks. i will try.