Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Complex numbers solution in Clear category for Three Points Circle by Leonix
def checkio(note):
a0, b0, c0 = (p[0] + p[1]*1j for p in eval(note)) # Read input coordinates as complex numbers.
a, b, c = 0.0, 1.0, (c0 - a0) / (b0 - a0) # Convert them into convenient frame of reference.
o = c/2 - c*1j*((c-1)/2/1j).imag / c.imag # Find center `o` of circumcircle of a triange [a, b, c].
o0 = o * (b0 - a0) + a0 # Convert `o` back into original frame of reference.
return "(x-{:.3g})^2+(y-{:.3g})^2={:.3g}^2".format(o0.real, o0.imag, round(abs(a0 - o0), 2))
Aug. 17, 2015
Comments: