首页 > 其他分享 >已知圆上3点求圆心和半径

已知圆上3点求圆心和半径

时间:2023-05-26 15:14:32浏览次数:40  
标签:x1 center 点求 y1 圆心 x2 圆上 y2 y3

转载:https://www.cnblogs.com/MaZai/p/10280674.html

点击查看代码
        void Calculate_cicular(Point px1, Point px2, Point px3,out Point center,out double r)
        {
            int x1, y1, x2, y2, x3, y3;
            int a, b, c, g, e, f;

            x1 = px1.X;//定义点的坐标
            y1 = px1.Y;
            x2 = px2.X;
            y2 = px2.Y;
            x3 = px3.X;
            y3 = px3.Y;

            e = 2 * (x2 - x1);
            f = 2 * (y2 - y1);
            g = x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1;

            a = 2 * (x3 - x2);
            b = 2 * (y3 - y2);
            c = x3 * x3 - x2 * x2 + y3 * y3 - y2 * y2;

             center = new Point();
            center.X = (g * b - c * f) / (e * b - a * f);
            center.Y = (a * g - c * e) / (a * f - b * e);

             r = Math.Sqrt((center.X - x1) * (center.X - x1) + (center.Y - y1) * (center.Y - y1));

        }

标签:x1,center,点求,y1,圆心,x2,圆上,y2,y3
From: https://www.cnblogs.com/solitaryclown/p/17434783.html

相关文章