title: find close pair of points in 3D
body: <p>I have a set of points in 3D which are sorted based on (X->Y->Z) coordinates. Some points (2 or 3 or even more) are very close to each other. I would like to find them and move them to a one point. <a href="https://i.stack.imgur.com/n2vXh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n2vXh.png" alt="enter image description here"></a></p>
  
  <p>I searched but most of algorithms I found only works in 2D. Note that I don't want to delete any points. I just want to move close ones to a single location (stitching). 
  I am only looking for an algorithm or if there is any opensource implementation in C++. </p>