0
votes

I am given 2 points inside a circle. I have to find a point on the circle (not inside, not outside) so that the sum of the distances between the given 2 points and the point i found is minimum. I only have to find the minimum distance, not the position of the point.

3
Could you please share, What you have tried so far?swiftBoy

3 Answers

4
votes

It is a minimization problem:

minimize sqrt((x1-x0)^2 + (y1-y0)^2) +  sqrt((x2-x0)^2 + (y2-y0)^2)
             ^                                         ^
     (distance from point1)                (distance from point 2)

subject to constraints:
x1 = C1
y1 = C2
x2 = C3
x4 = C4
x0^2 + y0^2 = r^2 
(assuming the coordinates are already aligned to the center of the circle as (0,0)).
(C1,C2,C3,C4,r) are given constants, just need to assign them.

After assigning x1,y1,x2,y2 - you are given a minimization problem with 2 variables (x0,y0) and a constraint. The minimization problem can be solved using lagrange multiplier.

0
votes

Let (x1, y1) and (x2, y2) be the points inside the circle, (x, y) be the point on the circle, r be the radius of the circle. Your problem reduces to a Lagrange conditional extremum problem, namely:

extremum function:

f(x, y) = sqrt((x-x1)^2 + (y-y1)^2) + sqrt((x-x2)^2 + (y-y2)^2)

condition:

g(x, y) = x^2 + y^2 = r^2  (1)

Introduce an auxiliary function(reference):

Λ(x, y, λ) = f(x, y) + λ(g(x, y) - r^2)

Let ∂Λ / ∂x = 0, we have:

(x-x1)/sqrt((x-x1)^2 + (y-y1)^2) + (x-x2)/sqrt((x-x2)^2 + (y-y2)^2) + 2λx = 0 (2)

Let ∂Λ / ∂y = 0, we have:

(y-y1)/sqrt((x-x1)^2 + (y-y1)^2) + (y-y2)/sqrt((x-x2)^2 + (y-y2)^2) + 2λy = 0 (3)

Now we have 3 variables(i.e. x, y and λ) and 3 equations(i.e. (1), (2) and (3)), so it's solvable.

Please be noted that there should be two solutions(unless two inside points happen to be the center of the circle). One is the minimal value(which is what you need), the other is the maximal value(which will be ignored).

0
votes

just another approach(which is more directly):

for simplicity, assume the circle is at (0,0) with radius r and suppose two points are P1(x1,y1) and P2(x2,y2)

we can calculate the polar angle of these two points, suppose they are alpha1 and alpha2 obviously, the point which is on the circle and having the minimum sum of distance to P1 and P2 is within the circular sector composed of alpha1 and alpha2

meanwhile, the sum of distance between the point on the circle within that sector and P1 and P2 is a quadratic function. so, the minimum distance can be found by using trichotomy.

figure: