Finding an equation of circle which passes through three points How to find the equation of a circle which passes through these points $(5,10), (-5,0),(9,-6)$
using the formula 
$(x-q)^2 + (y-p)^2 = r^2$.
I know i need to use that formula but have no idea how to start, I have tried to start but don't think my answer is right.

This method that I wrote creates a circle object which has a radius and a centre point. (written in Swift but can be port to many other languages.)

  func circle(p1: (x: Float,y: Float), p2: (x: Float,y: Float), p3: (x: Float,y: Float)) -> (r: Float, c: (x: Float,y: Float)) {
    let x1 = p1.x
    let x2 = p2.x
    let x3 = p3.x
    let y1 = p1.y
    let y2 = p2.y
    let y3 = p3.y

    let mr = (y2-y1) / (x2-x1);
    let mt = (y3-y2) / (x3-x2);

    if mr == mt { return nil }

    let x12 = x1 - x2;
    let x13 = x1 - x3;

    let y12 = y1 - y2;
    let y13 = y1 - y3;

    let y31 = y3 - y1;
    let y21 = y2 - y1;

    let x31 = x3 - x1;
    let x21 = x2 - x1;

    // x1^2 - x3^2
    let sx13 = pow(x1, 2) -
      pow(x3, 2);

    // y1^2 - y3^2
    let sy13 = pow(y1, 2) -
      pow(y3, 2)

    let sx21 = pow(x2, 2) -
      pow(x1, 2)

    let sy21 = pow(y2, 2) -
      pow(y1, 2)

    let f = ((sx13) * (x12)
      + (sy13) * (x12)
      + (sx21) * (x13)
      + (sy21) * (x13))
      / (2 * ((y31) * (x12) - (y21) * (x13)))
    let g = ((sx13) * (y12)
      + (sy13) * (y12)
      + (sx21) * (y13)
      + (sy21) * (y13))
      / (2 * ((x31) * (y12) - (x21) * (y13)))

    let c = -pow(x1, 2) - pow(y1, 2) -
      2 * g * x1 - 2 * f * y1;

    let h = -g;
    let k = -f;
    let sqr_of_r = h * h + k * k - c;

    let r = sqrt(sqr_of_r)

    return (r: r, center: (x: h, y: k))
  }


