A python wrapper around a subset of the ncollide rust library
Project description
========= ncollpyde
.. image:: https://img.shields.io/pypi/v/ncollpyde.svg :target: https://pypi.python.org/pypi/ncollpyde
.. image:: https://github.com/clbarnes/ncollpyde/workflows/.github/workflows/ci.yml/badge.svg :target: https://github.com/clbarnes/ncollpyde/actions :alt: Actions Status
.. image:: https://readthedocs.org/projects/ncollpyde/badge/?version=latest :target: https://ncollpyde.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black
A python wrapper around a subset of the ncollide rust library
- Free software: MIT License
- Documentation: https://ncollpyde.readthedocs.io.
Install
pip install ncollpyde
Pre-built wheels are available for Linux, MacOS, and Windows. If you have a stable rust compiler, you should also be able to install from source.
Features
- Checking whether points are inside a volume defined by a triangular mesh
- Checking the intersection of line segments with the mesh
Usage
.. code-block:: python
# get an array of vertices and triangles which refer to those points
import meshio
mesh = meshio.read("tests/teapot.stl")
vertices = mesh.points
triangles = mesh.cells_dict["triangle"]
# use this library
from ncollpyde import Volume
volume = Volume(vertices, triangles)
Containment checks:
.. code-block:: python
# individual points (as 3-length array-likes) can be checked with `in`
assert [-2.3051376, -4.1556454, 1.9047838] in volume
assert [-0.35222054, -0.513299, 7.6191354] not in volume
# many points (as an Nx3 array-like) can be checked with the `contains` method
bools = volume.contains(np.array([
[-2.3051376, -4.1556454, 1.9047838],
[-0.35222054, -0.513299, 7.6191354],
]))
assert np.array_equal(bools, [True, False])
# checks can be parallelised
volume.contains(np.random.random((1000, 3)), threads=4)
Note that v0.11 was the last to support meshio < 4.0
.
Known issues
- Performance gains for multi-threaded queries are underwhelming, especially for ray intersections: see
this issue <https://github.com/clbarnes/ncollpyde/issues/12>
- Very rare false positives for containment
- Due to a
bug in the underlying library <https://github.com/rustsim/ncollide/issues/335>
_ - Only happens when the point is outside the mesh and fires a ray which touches a single edge or vertex of the mesh.
- Also affects
is_backface
result for ray intersection checks
- Due to a
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for ncollpyde-0.14.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc180647d0365e4ed817df4b3a5c3ff2cb6fdee3600a03b61dd132fc4126bdff |
|
MD5 | dbe0b598f904093e49a627767cf1ded8 |
|
BLAKE2b-256 | f406e1880cfde8f3a09a94d57475f20f3b90e2f77a623636bc8e6a412fcfe7b2 |
Hashes for ncollpyde-0.14.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51ef4c2cb261512b39ce692f8c9cc7047baf717fbdb2f9e8896711f9af36db2 |
|
MD5 | f08ead5d5806fcc7ee957974e4df64b8 |
|
BLAKE2b-256 | eabbcf70df39a5a0d59d6aef0d5f3c398872184e806c94551b082755eaab9fb1 |
Hashes for ncollpyde-0.14.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eb50880a855b6931350ee2f471f8b111dc78ae51b0274b16be43f2ad0f29a89 |
|
MD5 | b4040bd65c88cfa5ef81e483bd7ece0c |
|
BLAKE2b-256 | 631852fe84f972826f93af5664ab1fdc3cfb2ccbcd7087d191462eb92077c1a2 |
Hashes for ncollpyde-0.14.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3a2ccfc23777dc799c7012bd9543963a2593a4b8a16b9c52ba972f733e37cda |
|
MD5 | f6dbf2502024d9d0a5f352334afe89e2 |
|
BLAKE2b-256 | c50912b0e2760e32d3ecb08c2ef65aa6406a411a665ee17683b02a726d1545c0 |
Hashes for ncollpyde-0.14.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9d84a9b8c8e09484309e6cce5bacbb472fb25a5dbf48c02f11750ba88a4c57a |
|
MD5 | c7ac40e8a886da5fdb58de8abefa69a5 |
|
BLAKE2b-256 | 70c975f2ee2778cba21b2b0ce7ba13cdd74b1001fa261acc47f84c0d342e6b16 |
Hashes for ncollpyde-0.14.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e442f48e8dfd2e8daec7606b1208d5cd416c0341074fc222ea9dc94e652f79d |
|
MD5 | f1aeb50694bcdd26e3f6f7328a42ca14 |
|
BLAKE2b-256 | 7aeb7aefe0b1eaa902d49a60e7f2b2be676f2c89207c90f1be3c570f3264f037 |
Hashes for ncollpyde-0.14.0-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d099d12e4ac1a0608f4a92089936ba7e0995dd151312346cd7ea9ae15d2426 |
|
MD5 | db0ae242dbe3a204489f043bb0d36fb8 |
|
BLAKE2b-256 | 2f0d8e0d3a535303abca6499b3fdccdea91cf2f3a23baebbe5b29e5627231629 |
Hashes for ncollpyde-0.14.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5665a5e292586ddde92a283b1e4009331bee8cf9cd87b5e3cac35de0b1d712b5 |
|
MD5 | 65771b4c05794b535979fcfb500bc153 |
|
BLAKE2b-256 | 8948458405fadc73e2f47a65cf4c61a11eaf46f679c1ff9da6e6358260b6fb4e |
Hashes for ncollpyde-0.14.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad222eeaf796d57ed40cb19e652ddd1ec6b32187cc664e93fc79df9b8c05f291 |
|
MD5 | 714a5a8e0b39b659447b4c703ae1bf9b |
|
BLAKE2b-256 | ecae484fdd566c17d6b9aef82c1d923b8441c255a6931835d33876086c01bb1b |