Find the coordinate at the minimum distance from the coordinate list

I have a list of coordinates in 2D space (x i, y i) How to find the coordinate (X, Y) so that the distance between it and other given coordinates is minimal? Is there a mathematical formula for solving (X, Y)?

Let me give you an example. Suppose I have a list co.ordinates (0,0); (1.0); (0,1); (- 1.0); (0, -1); Now I have to find possible co.ordinate (s) (one or many), so that the resulting co.ordination is at a minimum distance from all points. in this case (0,0).

As Voo said, this is my requirement: Find a point that minimizes the sum of the distances to the points in a given set

+3
source share
4 answers

,

.

- , ( , ) . ?

( ) , . a , . kd- .

+2
public Coord2D minDistance(List<Coord2D> coordinates, Coord2D someCoord) {
   float minDistance = Float.MAX_VALUE;
   Coord2D result;
   for (Coord2D coord : coordinates) {
       float distance = Math.sqrt(Math.pow((coord.x - someCoord.x), 2) + (Math.pow((coord.y - someCoord.y), 2))
       if (distance < result) { 
           result = coord;
           minDistance = distance;
       }
   }

   return result;
}
+1

, euclidien:     SquareRoot ((x1-) ยฒ + (YI-Y) ยฒ) :     | -Y | + | XI-X |.

?

0

Requirement: Find a point that minimizes the sum of the distances to the points in the given set.

A point with a minimum sum of Euclidean distance to all other points has:

x = average average of all X in the set y = average value for all Y in the set

0
source

All Articles