1

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. enter image description here

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++.

H'H
  • 1,638
  • 1
  • 15
  • 39
  • 2
    Why wouldn't alghoritms working in 2D not work in this case after adding additional dimension to distance measuring function? What complexity are you looking for? What stops you from implementing default O(n^2) solution? – Tomasz Plaskota Apr 14 '17 at 08:10
  • @TomaszPlaskota O(n^2) would comparing all pairs which is by default quite time consuming. I have around 100k points in minimum. I am wondering if there would be an smarter way to do so. – H'H Apr 14 '17 at 08:13
  • 2
    divide space into cubic cells by discretizing coordinates. Like int(x/2d) for each of x,y, and z. If points in same/adjacent cubic cell, group them. If you want spherical cells, do additional check. – hamster on wheels Apr 14 '17 at 08:17
  • @rxu nice idea. but what do you mean by additional check in spherical cells – H'H Apr 14 '17 at 08:19
  • don't know. if you want spherical cell, should group if pairwise distance < d. But, calculating all pairwise distances seems a waste. – hamster on wheels Apr 14 '17 at 08:20
  • 1
    @rxu Spherical cells are not a good idea as they cannot be overlap-free, which immediately requires them to have a ghost layer, which complicates things and costs performance. Cubic cells are the way to go, the traversal can then even be parallelized. – Henri Menke Apr 14 '17 at 08:23
  • 1
    @Heri Menke yea. Probably it is simplest to just pick a large enough d and do int(x/d) and then group everything in the same cubic cell. not really accurate because the boundary between two cell can divide points that are close to each other into two different cells. – hamster on wheels Apr 14 '17 at 08:26
  • 1
    You're looking for *point clustering*. Might be useful to do a search on that. One example: http://stackoverflow.com/questions/3482161/3d-clustering-algorithm – Jim Mischel Apr 14 '17 at 12:03
  • @rxu The boundary issue (two nearby points on opposite sides of cell wall) could be solved by having four discretization, with the three extra shifted by the cell length/2 in each of the Cartesian directions. – jwimberley Apr 14 '17 at 18:49

0 Answers0