def circle ( x1 , y1 , x2 , y2 , x3 , y3 ) : :return: x0 and y0 is center of a circle, r is radius of a circle a = x1 - x2 b = y1 - y2 c = x1 - x3 d = y1 - y3 a1 = ( ( x1 * x1 - x2 * x2 ) + ( y1 * y1 - y2 * y2 ) ) / 2.0 a2 = ( ( x1 * x1 - x3 * x3 ) + ( y1 * y1 - y3 * y3 ) ) / 2.0 theta = b * c - a * d if abs ( theta ) < 1e - 7 : raise RuntimeError ( 'There should be three different x & y !' ) x0 = ( b * a2 - d * a1 ) / theta y0 = ( c * a1 - a * a2 ) / theta r = np . sqrt ( pow ( ( x1 - x0 ) , 2 ) + pow ( ( y1 - y0 ) , 2 ) ) return x0 , y0 , r x0 , y0 , r = circle ( 48.955587 , - 122.745016 , 0 , 1 , 4 , 0 ) print ( "圆心: " + str ( x0 ) + " " + str ( y0 ) ) print ( "圆的半径: " + str ( r ) ) 推导细节请参考:https://blog.csdn.net/qq_17550379/article/details/78146201import numpy as npdef circle(x1, y1, x2, y2, x3, y3): """ :return: x0 and y0 is center of a circle, r is radius of a circle """ a = x1 - x2 b = y1 - y2 c = x1 -
三角形 心坐标 计算 公式 给定 三角形 三个 的坐标,如何求 三角形 的外心的坐标呢? 例如 :给定\(a(x1,y1) b(x2,y2) c(x3,y3)\)求外接圆 心坐标 \(O(x,y)\) 首先,外接圆的圆心是 三角形 三条边的垂直平分线的交 ,我们根据圆心到顶 的距离相等,可以列出以下方程: \[ (x1-x)*(x1-x)+(y1-y)*(y1-y)=(x2-x)*(x2-x)+(y2-y)*(...
如何 计算 曲线 y(x) ~y(x)~ y(x) 上的曲率,而曲线是由若干离散 构成 。我的第一反应是根据离散 差分得到一阶导数 y′ ~y'~ y′ 和二阶导数 y′′ ~y''~ y′′ ,然后由下式 计算 k=∣y′′∣(1+y′2)3/2... theta = np.linspace(0, 2*np.pi, 100) x1_circle = x1 + r * np.cos(theta) y1_circle = y1 + r * np.sin(theta) x2_circle = x2 + r * np.cos(theta) y2_circle = y2 + r * np.sin(theta) x3_circle = x3 + r * np.cos(theta) y3_circle = y3 + r * np.sin(theta) # 绘制 三个 圆 fig, ax = plt.subplots() ax.plot(x1_circle, y1_circle, color='b', label='Circle 1') ax.plot(x2_circle, y2_circle, color='r', label='Circle 2') ax.plot(x3_circle, y3_circle, color='g', label='Circle 3') ax.legend() # 设置坐标轴范围 ax.set_xlim(-1.5, 3.5) ax.set_ylim(-1.5, 1.5) # 显示图像 plt.show() 运行上述代码,可以得到 三个 半径 相同的 外切 圆的图像。