# Position in Circle given coordinates of points on the edge and distance to these points

PREFACE: I want to preface this question by saying that yes, I know it's been asked a few times here, and yes, I know that although what I am asking is the opposite of the usual question, it is possible to invert the given solutions and apply them to my problem. The issue here being that I am VERY rusty with mathematics and I'm looking for help in figuring out an exact algorithm for the question.

THAT SAID, the question I've found asked a dozen times on this page is "Given a point in a circle, two points on the edge, and the angles to those two points, find the distance to them". See here for an example: Find coordinates for points on circle given R, 2 Points, and angle or 2 points and center?

QUESTION: My question is almost the exact opposite: Given a point X in the circle, three points A, B and C on the circle and their coordinates, and the distance between X and A, B and C, find the coordinates of point X. For example:

CONCRETE EXAMPLE: Given a circle of Radius R = 500, points A = 0;0, B = 250;-250, C = 0;-500, and the distances of the edges XA = 414, XB = 334, XC = 87, find the coordinates of point X. Edit.: To clarify, point A is the center of the circle, not a point on its edge.

ASSUMPTIONS: I assume that the solution to this problem would involve the calculation of the angles for XA, XB and XC and then the application of the formula for finding the coords of point X. I will, however, have to execute this same calculation several times over the course of my work, and would like to code a computer program to resolve it for me. I could not, unfortunately, find one on the internet, though I did find this, which is pretty close: http://www.cncexpo.com/CircleCoord.aspx

Is there anyone that could point me to, or help me reach, an algorithm for this problem? I apologize for the messiness of the question, I am not used to formulating math questions. I will, of course, gladly make the program available upon completion so it can help others with the same problem in the future.

The length $XA=414$ means that if you draw a circle centred at $A$, with radius $414$, then this circle will pass through $X$. The same goes for $XB$ and $XC$.

This leads to a system of equations: $$(x - x_A)^2 + (y - y_A)^2 = (XA)^2\\ (x - x_B)^2 + (y - y_B)^2 = (XB)^2\\ (x - x_C)^2 + (y - y_C)^2 = (XC)^2$$

If the distances $XA, XB, XC$ are reported incorrectly, then there will be no solution; you may thus have to account for rounding errors.

Can you take it from here?

Incidentally, the radius you give in the example is wrong (it should be $250$, not $500$). But you don't need to provide the radius: it can be deduced from the positions of $A,B,C$, since any three points determine a unique circle. More critically, the example problem is impossible with the given co-ordinates and lengths. Even if we take the "best fit" point, i.e., the point that's approximately a solution, it is clearly not on the circle passing through $A,B,C$. Did you invent these numbers as an example without realizing that it was impossible? Or is there an error in the data?

• Apologies, point A in the given circle is actually the circle's center, not a point on the edge. The radius being 500 makes sense once you take that into consideration. However, I do have other points that can be used which would make the system of equations you gave a valid answer, and yes, I can take it from there quite easily. Thank you very much! – Fledgling Pidgeon Feb 9 '18 at 20:15
• @FledglingPidgeon Glad to help! Something still doesn't make sense, though, because if $A$ is the centre, then $AB$ should be the same as $AC$. – Théophile Feb 9 '18 at 20:18
• Ahh, that might be because the system I'm using is actually a simplification of a tridimensional system, with all points being "approximately" taken from the same Z to flatten it. However, there is the possibility of minor errors in that (give or take 1-3 units). Will that make the system impossible to resolve? Do you have a suggestion to account for that? The error caused by it is likely irrelevant to the results I'm looking for (it is not a serious piece of work, just an exercise). – Fledgling Pidgeon Feb 9 '18 at 20:23
• Since your data are noisy, you’ll likely need to look for a least-squares solution or other approximation. – amd Feb 9 '18 at 20:38
• The difference of each pair of equations above is the equation of a line that passes through the intersections of the respective circles. A simple way to deal with noisy data is to compute the centroid of the pairwise intersections of these lines. This might not be the best estimate of the true location, but lends itself to a direct, simple to implement computation. – amd Feb 9 '18 at 21:50