import math


def circle_from_three_points(p1, p2, p3):
    """ find the center position and radius of the circle going through all three points """

    x1, y1 = p1
    x2, y2 = p2
    x3, y3 = p3

    a = x2 - x1
    c = x3 - x1
    d = y2 - y1
    e = y3 - y1
    f = x1**2 - x2**2
    g = x1**2 - x3**2
    h = y1**2 - y2**2
    i = y1**2 - y3**2

    y = -1/2*(g + i + f*c/a + h*c/a)/(e - c*d/a)
    x = 1/2*f/a + 1/2*h/a - d/a*y
    r = math.sqrt((x1 - x)**2 + (y1 - y)**2)

    return (x, y), r