Centre of a circle that intersects two points

﹥>﹥吖頭↗ 提交于 2019-12-07 10:34:47

问题


Given two points in a 2D plane, and a circle of radius r that intersects both of those points, what would be the formula to calculate the centre of that circle?

I realise there would two places the circle can be positioned. I would want the circle whose centre is encountered first in a clockwise direction when sweeping the line that joins the two points around one of those points, starting from an arbitrary angle. I guess that is the next stage in my problem, after I find an answer for the first part.

I'm hoping the whole calculation can be done without trigonometry for speed. I'm starting with integer coordinates and will end with integer coordinates, if that helps.


回答1:


Not sure if this is the right place to ask this but:

let:

q = sqrt((x2-x1)^2 + (y2-y1)^2)
x3 = (x1+x2)/2
y3 = (y1+y2)/2

first circle:

x = x3 + sqrt(r^2-(q/2)^2)*(y1-y2)/q
y = y3 + sqrt(r^2-(q/2)^2)*(x2-x1)/q  

Second Circle:

x = x3 - sqrt(r^2-(q/2)^2)*(y1-y2)/q
y = y3 - sqrt(r^2-(q/2)^2)*(x2-x1)/q  

Here




回答2:


This has been answered over here: Ask Dr. Math: Finding the Center of a Circle from 2 Points and Radius

This may also be of interest: Gamedev.net: Circle centre given two points and radius.




回答3:


A=(ax, ay)
B=(bx, by)
d=((bx-ax)^2 + (by-ay)^2)^(1/2) # distance from A to B
r=radius of your circle

if (2*r>d) there is no solution in the real world - there is a complex solution ;-)

if (2*r=d) there is one solution : the middle between A and B.

Draw a line from A to B.
Draw the perpendicular from that line at the mid-point and out to a distance D such that r=(D^2 + (d/2)^2)^(1/2). Pick left or right depending on what you want.



来源:https://stackoverflow.com/questions/4914098/centre-of-a-circle-that-intersects-two-points

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!