Compute the smallest bounding ball of a point cloud. Cython binding of the popular miniball utility. Fast!
Project description
cyminiball
Compute the smallest bounding ball of a point cloud in arbitrary dimensions. A Python/Cython binding of the popular miniball utility by Bernd Gärtner.
The code is provided under the LGPLv3 license.
For an implementation in pure Python, see miniball
. cyminiball
can be used as a drop-in replacement for miniball
; it runs much faster because it is based on an effcient C++ implementation.
Installation:
pip install cyminiball
Usage:
import miniball
import numpy as np
d = 2 # Number of dimensions
n = 10000 # Number of points
dt = np.float # Data type
points = np.random.randn(n, d)
points = points.astype(dt)
C, r2 = miniball.compute(points)
print("Center:", C)
print("Radius:", np.sqrt(r2))
Additional output can be generated using the details
flag and compute_max_chord()
.
C, r2, info = miniball.compute(points, details=True)
# Returns an info dict with the following keys:
# center: center
# radius: radius
# support: indices of the support points
# relative_error: numerical error measure
# is_valid: numerical validity
# elapsed: time required
# The maximal chord is the longest line connecting any
# two of the support points. The folowing extends the
# info dict by the following keys:
# ids_max: ids of the two extreme points
# d_max: length of the maximal chord
info = compute_max_chord(points, info=info)
Build
To build the package requires
- Python 3.x
- Cython
- numpy
git clone https://github.com/hirsch-lab/cyminiball.git
cd cyminiball
python setup.py build_ext --inplace
python setup.py sdist bdist_wheel
python test/run_tests.py
python test/example.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cyminiball-1.0.0.tar.gz
(182.4 kB
view hashes)
Built Distribution
Close
Hashes for cyminiball-1.0.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06c1eda5e3f68d71641425f10dfd42449da20585f8f34a7327e2071e25312f44 |
|
MD5 | 2ebb53542ea3738314700b156ed28983 |
|
BLAKE2b-256 | 1ebcffb6ab1f7ae295dce57c91836900cb0eb7331e5b13fe52c56d33b1df3887 |