N-Dimensional hypersphere.
Use this if you want to obtain all the neighbors within a given radius from a point in a space with arbitrary number of dimensions assuming that the space is discrete.
No validation of producing coordinates within any extent is done.
Examples
Create a Sphere of diameter 1 and obtain all coordinates within range for the coordinate (1,1,1).
>>> s = Sphere(1)
>>> s((2, 1))
[(1, 1), (2, 0), (2, 1), (2, 2), (3, 1)]
>>> s((1, ))
[(0,), (1,), (2,)]
If elements in discrete space have different sizes across dimensions, it might be preferable to specify element_sizes parameter.
>>> s = Sphere(2, element_sizes=(1.5, 2.5))
>>> s((2, 1))
[(1, 1), (2, 1), (3, 1)]
>>> s = Sphere(1, element_sizes=(1.5, 0.4))
>>> s((2, 1))
[(2, -1), (2, 0), (2, 1), (2, 2), (2, 3)]
Initialize the Sphere
Parameters : | radius : float
element_sizes : None or iterable of floats
distance_func : None or lambda
|
---|