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_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
- 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.12.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d56fcf64a438aa9d0fefd69c5ba0b308112d67084678da8decb5434b79db429 |
|
MD5 | ac2255cc059d1a78ee1093d285d96c02 |
|
BLAKE2b-256 | 258d4f809848a964e589bdb7ce36b64326d29e33ed0973f39d4e7bafe1ca524c |
Hashes for ncollpyde-0.12.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a961efb3fa6834e14e0639b731b7bbf35bb222f7eb51b40c863c272d91d580a5 |
|
MD5 | 1372c93f897ee4573f6e44c667c87cc7 |
|
BLAKE2b-256 | 6ce04537524d054e72a3c732c47715baa0c098be72458aaafc525d20261160e4 |
Hashes for ncollpyde-0.12.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 425484e24975a8d4de4603e9b916a104f21818ccc015eac1aeaf5a79be4a921d |
|
MD5 | 2be156bf15d311c0bd464244e1e2218c |
|
BLAKE2b-256 | 99b24a0b2822a19251176ae680cae7f758b23b19931a17391d7a5762c333f7b5 |
Hashes for ncollpyde-0.12.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 920732cfd6539e21482b6766711eb69dbf6bb951b1f09481dcb67cf1d06cd2ed |
|
MD5 | b60c7b07bfad904fbdf940d80c6a47f8 |
|
BLAKE2b-256 | 5ff5da1b081e0983b0becc32a383bb4ac926c61e191c952edd3d46a4b60612d7 |
Hashes for ncollpyde-0.12.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e569c07cb237fd2b828dc1f9f7006092b9dd09f342562b1560d87040a35bc51 |
|
MD5 | e043b292ba3eba622417223a00729265 |
|
BLAKE2b-256 | 734d315a1b85ce1aeb897926df836910ad5a3dfae177a9f81b476eddc24df5c2 |
Hashes for ncollpyde-0.12.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a827762c181fd142e9b630f05088e8dd3dd389214a31ec9ad73e9483cee3ae |
|
MD5 | a8a2373b8d76ba40b337170b5fee5197 |
|
BLAKE2b-256 | 61574666823395de9a3f984b5976001dc47a1d4c9d471cb1e30c88b7ffb018fb |
Hashes for ncollpyde-0.12.0-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04550554890b39c1169335f7e53f24e08ca167de423968bc2a5c7aa10c46eb74 |
|
MD5 | c5ff0ddf8e6773ebbf3779874ed3287f |
|
BLAKE2b-256 | 5e64df326becad3cd465bd8f0ab7851a7821f15f833e84bf9a684d0c24fb84f1 |
Hashes for ncollpyde-0.12.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de32eb7e801f4635f26ea8393fb230109661baf2665dcbb9ad99d2aa1c605b3f |
|
MD5 | 4e929f7f03bebe2de006581cd6b1f28d |
|
BLAKE2b-256 | 07e8c8d45c5484e69ac8d21f68efb831c62c3b853836a27dbf588e83cea4e781 |
Hashes for ncollpyde-0.12.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36074b07bfe269117b24f8b1f3aebf714ebaad4f3f747abde69fdb963888d44e |
|
MD5 | 68de9293073d5ead23a54b73cedb56e4 |
|
BLAKE2b-256 | 26c31a906c1ea8c7a3d62d04db7979cb3b968a60e34a4342884ba1f17181590b |