求两个圆之间的距离
我试图弄清楚如何获得两个圆相对于其方形容器盒的角的距离。我需要一些数学方面的帮助。
如何计算出标有问号的线的像素数?
一如既往地感谢帮助。
I'm trying to figure out how to get the distance from two circles relative to the corners of their square container boxes. I need some help with the maths here.
How can I work out the number of pixels for the line marked with a question mark?
Appreciate the help as always.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
tldr:计算每个圆中心点之间的距离,然后从中减去每个圆的半径。
为了演示的目的,我们将假设如下:
r1 = 100
) 的圆位于 (x, y) 坐标(0, 0)
,r2 = 50
) 的圆位于(150, -150)
的 (x, y) 坐标处。假设它们的中心之间的距离是:
要找到它们边界之间的距离,我们减去半径< /strong> 每个圆的中心之间的距离。
这给我们留下了等式:
将您的值插入上面给出:
tldr: Calculate the distance between each circles center point, then subtract the radius' of each circle from that.
For the purpose of a demonstration, we will assume the following:
r1 = 100
) circle is at the (x, y) coordinates of(0, 0)
, andr2 = 50
) circle is at (x, y) coordinates of(150, -150)
.Given that the distance between their centers is:
To find the distance between their boundaries, we subtract the radius of each circle from the distance between their centers.
This leaves us with the equation:
Inserting your values into the above gives:
你有每个圆圈的中点吗?如果这样做,首先计算距圆心的距离。
distance² = center1² + center2²
然后,您需要减去两个圆的半径。在您的情况下,它将是 150 (100 + 50)
Do you have the middle point of each circles? If you do, first calculate the distance from the centre of circles.
distance² = center1² + center2²
Then, you will need to minus the radius of both circles. In your case, it will be 150 (100 + 50)
让我们看看......每个半径都是每条边长的一半,从中心之间的距离减去半径之和即可得到剩下的量。
希望有帮助吗?
Let's see... each radius is half each side length, and subtracting the sum of the radii from the distance between the center gives you the amount that's left.
Hope that helps?
Daniel 答案的代数简化版本是
其中 r1,r2 是两个半径,s1,s2 是两个正方形边。通过单独查看每个正方形并注意从圆/正方形中心到正方形角的距离 d1 是 sqrt(2) * r,并且该正方形内所需的距离是 d1 - 圆半径 r,很容易看出这一点。
The algebraically simplified version of Daniel's answer is
where r1,r2 are the two radii and s1,s2 are the two square sides. This is easily seen by looking at each square individually and noticing that the distance d1 from the circle/square center to the square corner is sqrt(2) * r, and the desired distance within that square is d1 - the circle radius r.