The center of a circle that intersects two points

Given two points in a two-dimensional plane and a circle of radius r that intersects both of these points, what will be the formula for calculating the center of this circle?

I understand that two circles could be placed. I would like the circle, the center of which occurs first in a clockwise direction, to sweep the line connecting two points around one of these points, starting from an arbitrary angle. I assume that this is the next stage of my problem, after I find the answer for the first part.

I hope that the whole calculation can be done without trigonometry for speed. I start with integer coordinates and end with integer coordinates if that helps.

+4
source share
3 answers

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

let be:

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

+5
source

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) in the real world there is no solution - 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 a perpendicular from this line at the midpoint and at a distance D such that r = (D ^ 2 + (d / 2) ^ 2) ^ (1/2). Choose left or right depending on what you want.

+2
source

Source: https://habr.com/ru/post/1338636/


All Articles