'Implementing a sliding window(cube) to crop a point cloud in Python

I want to crop a very large point cloud. I only have np.array of 3D coordinates of these points

[[  165.  1958.  3832.]
 [  165.  1958.  3833.]
 [  165.  1958.  3834.]
 ...
 [ 6090. 11602.  9475.]
 [ 6090. 11602.  9476.]
 [ 6090. 11602.  9477.]]

I was considering to implement a sliding window(cube) technique. Basically I assumed these N points are in large volume and I want to iterate sliding window inside of this large volume to crop subvolumes with a certain number of points.

For example if I have a cube with a fixed size of 20x20x20 and my sliding cube starts at [160,1958,3213] I want to have indices of points [ 165. 1958. 3832.] and [ 165. 1958. 3833.] which is [0,1] In next iteration my sliding cube will start at [180,1978,3233]

Since N is very large I can't create a new volume and occupy indices of point cloud and brute-force my way. Is there any efficient way to do this in Python? I am open to new ideas as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source