What is the algorithm for finding the center of a circle from three points?

前端 未结 6 1996
慢半拍i
慢半拍i 2020-12-02 15:54

I have three points on the circumference of a circle:

pt A = (A.x, A.y);
pt B = (B.x, B.y);
pt C = (C.x, C.y);

How do I calculate the cente

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 16:11

    def circle_mid_point(list_b):
    list_k = []
    for i in range(3):
        for j in range(1,4):
            if i+j <=3:
                midpoint_x1 =  (list_b[i][0] + list_b[i+j][0])/2
                midpoint_y1 = (list_b[i][1] + list_b[i + j][1]) / 2
                list_k.append([midpoint_x1,midpoint_y1]) # list of all the midpoints of the lines
    
    for k in range(len(list_k)):
        for j in range(1,len(list_k)-1):
            if list_k[k] == list_k[k+j]: #at centre only two midpoints will have the same value
                return list_k[k]
    
    k = circle_mid_point([[0,1],[1,0],[-1,0],[0,-1]])
    print(k)
    

提交回复
热议问题