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.13.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f64c1b9b9ecbd442c667d7e92be3f881de9e9ccf4eabdb37edc6e2ce07bb5a9 |
|
MD5 | 7f01efc34af7f269ea32ed2045074660 |
|
BLAKE2b-256 | e4c68aeb2cbe90d73cbbc434ca8c4a5f400c8666e6be6d0cc4f9bbfbbd92a42b |
Hashes for ncollpyde-0.13.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df14650c51070e285456c75e3fde279a92c2b350d407cb9338a43b23ee668382 |
|
MD5 | 08b6652b99307f6c841ceb3c1d55cd61 |
|
BLAKE2b-256 | eeb00fea20656807b0fb3ece6e982ec2855b13f2d094cdcb3c0b64ef486fc455 |
Hashes for ncollpyde-0.13.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14000cc792c6da5034d7b08e41260557112fa0fb9ba5e02fad39d450606ddc8a |
|
MD5 | 42357a897199fa42165ce68ba9ae0607 |
|
BLAKE2b-256 | 5327f1bca33ced92d8499ca14c46d577ee047c82fcecb31851ae5f48f0c24391 |
Hashes for ncollpyde-0.13.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae1078fd53086688ce8392c9dd236771d9e483618ab3abf77e2ae7ab942bb1a |
|
MD5 | 952ffc0b976d136d90effde34b6e56bc |
|
BLAKE2b-256 | 6c7e1447b817484208a0957a382c716f505d26b52b24f8d6fe6ed1cd23f668ef |
Hashes for ncollpyde-0.13.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72d0105803afa618b3f2b6368b408713d92ee7071996694db90145f75e0b0600 |
|
MD5 | 4f67a1d0a9afef5c32d59fe5f0c62cf2 |
|
BLAKE2b-256 | 9a19cd1fab91a88afc64ffde9872dea1047d45404578d117895b2fad77173883 |
Hashes for ncollpyde-0.13.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc31f90f9d0447f535eb7f32111b49898d7a5a9c197e3f4ee54d007e242fb555 |
|
MD5 | f1625c5771332c8afe420c10e640793e |
|
BLAKE2b-256 | 19f111661e3fbbcad93cf7471a94c2fb09dfa5c965f40acabf0f51be0db020aa |
Hashes for ncollpyde-0.13.0-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abc2f241eaabe4f656f02a011b149b667914ef1b54042b4cb163620327244e5e |
|
MD5 | 8c88c3f3fc413364ffbd94a8064ceb8e |
|
BLAKE2b-256 | 487a12c0b5dc5049c3f712c9fc6ab227f91aece7de162fd81810b9330c2aadd5 |
Hashes for ncollpyde-0.13.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39dc7a849b3bbba3be994b5b9d181859c941b4ad55da4240b6bbeb02c5c89d8d |
|
MD5 | 6822cad5300e9b0f397acaf6d84cb3da |
|
BLAKE2b-256 | ef4631051bff69f5aea1665d61ee172ed59c1d176c96360559385c1c709feb7f |
Hashes for ncollpyde-0.13.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbe72f71bc879101f7db4413cb9ea543328df9adcbe8d261d98ae7ecaddcab58 |
|
MD5 | 7c3adb377b93de045a2c64e7ae5ac45c |
|
BLAKE2b-256 | 281df0fa24e0fe96cd515830c31dd67d66bb6c137c806cceb094d1343a4ed578 |