过平面三点求圆的圆心和半径

设平面三点v0,v1,v2 求过三点的圆的圆心c?
解:
由圆的方程
( x − x c ) 2 + ( y − y c ) 2 = r 2 (x-x_c)^2+(y-y_c)^2=r^2 (xxc)2+(yyc)2=r2 (1)

将三点代入(1)得到:
( x 0 − x c ) 2 + ( y 0 − y c ) 2 = r 2 (x_0-x_c)^2+(y_0-y_c)^2=r^2 (x0xc)2+(y0yc)2=r2 (2)
( x 1 − x c ) 2 + ( y 1 − y c ) 2 = r 2 (x_1-x_c)^2+(y_1-y_c)^2=r^2 (x1xc)2+(y1yc)2=r2 (3)
( x 2 − x c ) 2 + ( y 2 − y c ) 2 = r 2 (x_2-x_c)^2+(y_2-y_c)^2=r^2 (x2xc)2+(y2yc)2=r2 (4)

(2)-(3)得
( 2 ∗ x 1 − 2 ∗ x 0 ) ∗ x c + ( 2 ∗ y 1 − 2 ∗ y 0 ) ∗ y c = x 1 2 + y 1 2 − x 0 2 − y 0 2 (2*x_1-2*x_0)*x_c+(2*y_1-2*y_0)*yc=x_1^2+y_1^2-x_0^2-y_0^2 (2x12x0)xc+(2y12y0)yc=x12+y12x02y02 (A)

(3)-(4)得
( 2 ∗ x 2 − 2 ∗ x 1 ) ∗ x c + ( 2 ∗ y 2 − 2 ∗ y 1 ) ∗ y c = x 2 2 + y 2 2 − x 1 2 − y 1 2 (2*x_2-2*x_1)*x_c+(2*y_2-2*y_1)*yc=x_2^2+y_2^2-x_1^2-y_1^2 (2x22x1)xc+(2y22y1)yc=x22+y22x12y12 (B)

则A,B构成一个二元一次方程组

[ a 0 b 0 a 1 b 1 ] [ x c y c ] = [ d 0 d 1 ] \begin{bmatrix} a_0 & b_0 \\ a_1 & b_1 \end{bmatrix} \begin{bmatrix} x_c \\ y_c \end{bmatrix} = \begin{bmatrix} d_0 \\ d_1 \end{bmatrix} [a0a1b0b1][xcyc]=[d0d1]
采用克莱姆法可以计算出xc(xc, yc),当分母 a 0 ∗ b 1 − a 1 ∗ b 0 a_0*b_1-a_1*b_0 a0b1a1b0接近0,则无解。
知道圆心,则代入(1)可以求出半径r。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个用C语言实现的平面三点圆心的代码示例: ```c #include <stdio.h> #include <math.h> struct Point { double x; double y; }; struct Circle { struct Point center; double radius; }; struct Circle calculateCircle(struct Point p1, struct Point p2, struct Point p3) { struct Circle circle; // 计算中垂线的斜率 double slope1 = (p2.y - p1.y) / (p2.x - p1.x); double slope2 = (p3.y - p2.y) / (p3.x - p2.x); // 计算中垂线的中坐标 double midX = (slope1 * slope2 * (p1.y - p3.y) + slope2 * (p1.x + p2.x) - slope1 * (p2.x + p3.x)) / (2 * (slope2 - slope1)); double midY = -1 * (midX - (p1.x + p2.x) / 2) / slope1 + (p1.y + p2.y) / 2; // 计算圆心坐标和半径 circle.center.x = midX; circle.center.y = midY; circle.radius = sqrt(pow(p1.x - midX, 2) + pow(p1.y - midY, 2)); return circle; } int main() { struct Point p1, p2, p3; struct Circle circle; printf("请输入三个的坐标:\n"); printf("1的x坐标:"); scanf("%lf", &p1.x); printf("1的y坐标:"); scanf("%lf", &p1.y); printf("2的x坐标:"); scanf("%lf", &p2.x); printf("2的y坐标:"); scanf("%lf", &p2.y); printf("3的x坐标:"); scanf("%lf", &p3.x); printf("3的y坐标:"); scanf("%lf", &p3.y); circle = calculateCircle(p1, p2, p3); printf("圆心坐标:(%lf, %lf)\n", circle.center.x, circle.center.y); printf("半径:%lf\n", circle.radius); return 0; } ``` 这段代码通过输入三个的坐标,计算出通过这三个圆心坐标和半径。请注意,代码中使用了结构体来表示,方便进行数据的存储和传递。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值