求助,计算俩圆交点坐标
求助,
已知,如图,x1=130, y1=130, r1=80, x2=190, y2=210, r2=60.
求俩圆交点坐标。
[此贴子已经被作者于2022-4-20 00:24编辑过]
#include <stdio.h> #include <math.h> int main() { float a=5; float b=-1812; float c=160020; float d=b*b-4*a*c; float y1=(-b+sqrt(d))/10; float y2=(-b-sqrt(d))/10; float x1=410.0-4.0/3.0*y1; float x2=410.0-4.0/3.0*y2; printf("交点一坐标 (x:%.2f,y:%0.2f)",x1,y1); printf("交点二坐标 (x:%.2f,y:%0.2f)",x2,y2); printf("验证:\n"); printf("左侧:%.2f 右侧:%.2f \n",(x1-130)*(x1-130)+(y1-130)*(y1-130),80.0*80.0); printf("左侧:%.2f 右侧:%.2f \n",(x2-190)*(x2-190)+(y2-210)*(y2-210),60.0*60.0); return 0; } /* PS C:\Users\Administrator> ./ct 交点一坐标 (x:130.00,y:210.00)交点二坐标 (x:206.80,y:152.40)验证: 左侧:6400.00 右侧:6400.00 左侧:3600.00 右侧:3600.00 */
from sympy import * import math x=Symbol("x") y=Symbol("y") solved = solve([(x-130)**2+(y-130)**2-80*80,(x-190)**2+(y-210)**2-60*60], [x, y]) for i, v in enumerate(solved): print(f"x{i}: {v[0].round(5)}, y{i}: {v[1].round(3)}") # 保留 3 位小数 ''' PS C:\Users\Administrator> & C:/Programs/Python/python.exe d:/wp/toutiao.py x0: 130, y0: 210 x1: 206.80000, y1: 152.400 '''