これを試して:
List<Point> V1 = new List<Point>();
V1.Add(new Point(2, 2));
V1.Add(new Point(4, 4));
V1.Add(new Point(6, 6));
V1.Add(new Point(8, 8));
V1.Add(new Point(10, 10));
List<Point> V2 = new List<Point>();
V2.Add(new Point(1, 1));
V2.Add(new Point(3, 3));
V2.Add(new Point(5, 5));
V2.Add(new Point(7, 7));
V2.Add(new Point(9, 9));
List<Point> result = new List<Point>();
foreach (Point p1 in V1)
{
Point minPoint = Point.Empty;
double minDist = double.MaxValue;
foreach (Point p2 in V2)
{
double dist = Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
if (dist < minDist)
{
minDist = dist;
minPoint = p2;
}
}
result.Add(minPoint);
}
追加の最適化として、Math.Sqrt
正確な距離は実際には必要ないため、を削除できます。