Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Math 计算最接近两个圆交点的圆坐标_Math_Svg_Language Agnostic_Geometry - Fatal编程技术网

Math 计算最接近两个圆交点的圆坐标

Math 计算最接近两个圆交点的圆坐标,math,svg,language-agnostic,geometry,Math,Svg,Language Agnostic,Geometry,我有两个可以相交的圆,如果是这样的话,我会计算最大圆的坐标,这个最大圆近似于这个相交区域 我用svg绘制了一个草图来表示问题: <svg width="400" height="400"> <line x1="85" y1="50" x2="140" y2="70" stroke="rgb(50,50,50)" stroke-width="1" /> <circle cx="85" cy="50" r="50" stroke="rgba(50,50,

我有两个可以相交的圆,如果是这样的话,我会计算最大圆的坐标,这个最大圆近似于这个相交区域

我用svg绘制了一个草图来表示问题:

<svg width="400" height="400">
    <line x1="85" y1="50" x2="140" y2="70" stroke="rgb(50,50,50)" stroke-width="1" />
    <circle cx="85" cy="50" r="50" stroke="rgba(50,50,50,0.8)" stroke-width="1" fill="rgba(0,0,150,0.3)" />
    <circle cx="140" cy="70" r="40" stroke="rgba(50,50,50,0.8)" stroke-width="1" fill="rgba(150,0,0,0.3)" />

    <circle cx="117" cy="62" r="16" stroke="rgba(50,50,50,0.8)" stroke-width="1" fill="rgba(00,150,0,0.3)" />
</svg>

您可以在此处联机尝试:

有了前两个圆,我会得到第三个圆的中心和半径(在我用手画的例子中)

A, r1 = center, radius of first circle
B, r2 = center, radius of second circle
是给定的输入数据,并且

C, r3 = center, radius of third circle
是与前两个圆相交的最大圆

表示为

D = intersection point of first with third circle
E = intersection point of second with third circle
D和E是连接中心A和B的线上的点。D的距离为r1 A和E与B的距离为r2。因此

D = A + r1 * (B - A)/dist(A, B)
E = B - r2 * (B - A)/dist(A, B)
由此

C  = (D + E)/2    = (A + B + (r1 - r2)*(B - A)/dist(A, B)) / 2
r3 = dist(D, E)/2 = (r1 + r2 - dist(A, B)) / 2
如果
r3<0
,则这些圆根本不相交


(上述计算假设没有一个圆完全位于另一个圆内。)

你所说的“近似”相交区域是什么意思您的联机SVG在我的浏览器中不起作用,也许您可以在问题中添加一个图像。tryit中的代码与上面的代码不匹配,如果您将代码替换为上面的代码,则您确实需要diagram@jing3142:这很有道理,谢谢!很抱歉造成误解,但是如果我删除该参数,页面将无法工作,它需要一个“文件名”