coords.Coords.boxes#

Coords.boxes(ppb=1, shift=0.5, minsize=1e-05)#

Create a grid of equally sized boxes spanning the Coords.

A regular 3D grid of equally sized boxes is created enclosing all the points of the Coords. The size, position and number of boxes are determined from the specified parameters.

Parameters#

ppb: int

Average number of points per box. The box sizes and number of boxes will be determined to approximate this number.

shift: float (0.0 .. 1.0)

Relative shift value for the grid. Applying a shift of 0.5 will make the lowest coordinate values fall at the center of the outer boxes.

minsize: float

Absolute minimal size of the boxes, in each coordinate direction.

Returns#

ox: float array (3,)

The minimal coordinates of the box grid.

dx: float array (3,)

The box size in the three global axis directions.

nx: int array (3,)

Number of boxes in each of the coordinate directions.

Notes#

The primary purpose of this method is its use in the fuse() method. The boxes allow to quickly label the points inside each box with an integer value (the box number), so that it becomes easy to find close points by their same label.

Because of the possibility that two very close points fall in different boxes (if they happen to be close to a box border), procedures based on these boxes are often repeated twice, with a different shift value.

Examples#

>>> X = Coords([[5,3,0],[2,4,3],[2,3,3],[5,6,2]])
>>> print(*X.boxes())
[ 0.5  1.5 -1.5] [3.  3.  3.] [2 2 2]
>>> print(* X.boxes(shift=0.1))
[ 1.7  2.7 -0.3] [3.  3.  3.] [2 2 2]
>>> X = Coords([[1.,1.,0.],[1.001,1.,0.],[1.1,1.,0.]])
>>> print(*X.boxes())
[ 0.9833  0.9833 -0.0167] [0.0333 0.0333 0.0333] [4 1 1]