A python wrapper around a subset of the ncollide rust library
Project description
========= ncollpyde
.. image:: https://img.shields.io/pypi/pyversions/ncollpyde.svg :target: https://pypi.python.org/pypi/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?branch=master :target: https://github.com/clbarnes/ncollpyde/workflows/.github/workflows/ci.yml
.. 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["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)
Known issues
- Benchmarks suggest that multithreaded performance is about the same as serial
- 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.
- 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.11.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba24d5677871d7fa0bda16f48f0594eb512fa3a2edc795fbc08997e1696d83ae |
|
MD5 | ccad3e7642a2cf9ebada7c2607a8eb7a |
|
BLAKE2b-256 | bdaee1a1540eec19719257d3af86fe5026f74390a146347478a6fb6464f9270d |
Hashes for ncollpyde-0.11.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 053208ddd7bc4d6527590d96750a23b33f9e3dd755fadf0ef390742cc93114b1 |
|
MD5 | da3c459cf1cdcf2e13024d8c0f9a8a94 |
|
BLAKE2b-256 | 3af866fa6a979708ab63ea47b5baaa28de10b0c5a469007b05760866cec12239 |
Hashes for ncollpyde-0.11.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff371934dce8e5571dc48f94d94aab9955f9a9c8d0ad1bcc74058765edfbdbec |
|
MD5 | 59b7157eca4cd9d5ed2ed60fcd48a9af |
|
BLAKE2b-256 | 0f6807924e621e16939743578fb89e5d1f9c5877f099561be298e7e4a439aafd |
Hashes for ncollpyde-0.11.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddf6cd6efe530b66122df7faf1153371102eb6f702b3f610b871123592e0b613 |
|
MD5 | 55f0b8b7407a0b86ef534ab5676d414b |
|
BLAKE2b-256 | 8929a40e794a3430ae62c8451b0161d0989f0c7ce6963824ae51d67ae55e26ae |
Hashes for ncollpyde-0.11.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fb9d0125f7668d8332af7b8e595c2603bce3a756843e6dd0f35442ea84db2a3 |
|
MD5 | ad21333313da73fd6e969ede642b38b0 |
|
BLAKE2b-256 | 4d550aa5670663f04ecbf04e94d281c349d703017a9cadb7ce9d018501b57cbc |
Hashes for ncollpyde-0.11.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58a152d260e20a294630cf6ae6151bc0e19a813798df2506a67c2d61faed995d |
|
MD5 | 76a7cb6ba7f9c96be7717a694750e27d |
|
BLAKE2b-256 | 918a01d4d8105f35ad253f68be89ffc90a403fb22cf252ae953217af4c066df3 |
Hashes for ncollpyde-0.11.0-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dea8e88fe5c97ed5e8b34e8189297208e7bb85b36e5afeaa5862d9d04fb3cf0 |
|
MD5 | 652619c8dc21517cc51abdd3ca1bedcc |
|
BLAKE2b-256 | 9b60058f103556bc6ffcd548c2c8e76fee2a4198939e0cc2b49605ce63da944e |
Hashes for ncollpyde-0.11.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de286419b6a9b9c361d879a052317112baf85843e92e6bbe94e5f79dba9a2d77 |
|
MD5 | 52fc08468d2c3157b59545d8154ea97a |
|
BLAKE2b-256 | 5451c455780b3b350ea9f3dc6db663ef3b0308033f64ad64ec4179c220fc1735 |
Hashes for ncollpyde-0.11.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 540e440b6de5443e6ab71512249ebed0cb2d3b1dff644e00dd1de4dbf9846272 |
|
MD5 | 4436e13c88a6da8fa2021094b0b1eb75 |
|
BLAKE2b-256 | 8aee229f3e040a5347bb47c2bd181e2bb63fcc96aa99372307281118ca17c915 |