PCL Gets the two closest points in the point set (two-dimensional)

1. Introduction

Given a point set of n points on a plane, the problem is to find the closest pair of points in the point set. This problem arises frequently in many applications, for example, in air traffic control, to monitor aircraft that are getting too close, as this could lead to a collision. Here is a way to obtain these two points. The specific calculation process is as follows:

  1. Firstly, the point set is sorted according to the x coordinate, which is convenient for the subsequent segmentation operation.
  2. Finds the middle point in the sorted set of points, based on which the given set of points is split in half.
  3. Recursively find the minimum distance between two points in two subsets, as shown in the figure below.
  1. From the above 3 steps, we get the upper bound d of the minimum distance. Now we need to consider the case of pairs where one point comes from the left half and the other point comes from the right half. Consider the vertical line passing through the middle point, find all points whose x coordinates are closer to the middle vertical line than d, and create a strip array to collect all these eligible points.

Guess you like

Origin blog.csdn.net/dayuhaitang1/article/details/131747455