function [Px,Py]=circle_center(Ax,Ay,Bx,By,Cx,Cy) % [Ax,Ay], [Bx,By], [Cx,Cy] are three points on the circle % [Px,Py] are the center of the circle Px=-((Bx - Cx)*(Bx/2 + Cx/2) + (By - Cy)*(By/2 + Cy/2 - (Ay^2 - Bx^2 - Bx*By + Ax*Bx - By^2 + Ax*By)/(2*Ay - 2*By)))/(Cx - Bx + ((By - Cy)*(2*Ax - 2*Bx))/(2*Ay - 2*By)); Py=(Ay^2 - Bx^2 - By^2 + Ax*Bx + Ax*By - Bx*By - 2*Ax*Px + 2*Bx*Px)/(2*Ay - 2*By); figure; hold on; plot(Ax,Ay,'*'); plot(Bx,By,'o'); plot(Cx,Cy,'x'); plot(Px,Py,'+'); title('Three points and computed center'); legend('A','B','C','P') end