A python wrapper around a subset of the ncollide rust library
Project description
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
# 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:
# 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
- Very rare false positives for containment
Due to a bug in the underlying library
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
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.15.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6fe2337bd9d7bf4a6aeda03a9b03444d2d6051a7f4290519aed56f16c3a74d2 |
|
MD5 | 9f9061d47d53a4284518ede26ec926d7 |
|
BLAKE2b-256 | 0ec6aad369b55cf052797085306a7715a859c89afea271ba4690e3dfa8eb1fdd |
Hashes for ncollpyde-0.15.2-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df96a019b8714072f58f651af9f58b437167b619b1d82e7bd1404923d86699b |
|
MD5 | 7975cca1272fa1717807f3f7667097f8 |
|
BLAKE2b-256 | 51476b5f7321fa0aa8b5e11aed9d323c2011a0a9ad80025b6eabedb7cca0d02b |
Hashes for ncollpyde-0.15.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 580ca9702d735045b37841cedc3b6cef4f9b4c0781dde6b4f20e3c4472dcbe8b |
|
MD5 | 28db24677cd25074d934ff3155a03e60 |
|
BLAKE2b-256 | 3eca45b5e4d0e83dba51f89087cad29e5ea02b9f92100be074e1c19ccb879c3a |
Hashes for ncollpyde-0.15.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cad64aab652b5a80e82c22eca61a47edb46c90d3441299515704201c0463487 |
|
MD5 | 7942187d70fab7e2962570d33589ee73 |
|
BLAKE2b-256 | 6bc120d7d7d9b0d06b69205f4bf409da52dbf1f8036bf9acc0479aa8b18bde2f |
Hashes for ncollpyde-0.15.2-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7071564cc2143bec771cae79f93f38d491e4884e2b52a31459aefb459c128f50 |
|
MD5 | 09a1d44d8d73ebcc8706edb2cbbf8987 |
|
BLAKE2b-256 | a2f493d5d8a1e705c3bdb525bcb402b4dc59913625212791ff16468c86b723e9 |
Hashes for ncollpyde-0.15.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79f3a53ae858a1155acc5a020e0be407b69e039357dc8244215e7965751d8022 |
|
MD5 | 707c7d931debbe094692a223abfbe90c |
|
BLAKE2b-256 | a811cd6e2c38d7b013359a5f697ab71f9a61c873c1133b671a5fcdc61cbb8b0e |
Hashes for ncollpyde-0.15.2-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e55d81ac933fe125687080a93df31cbb31817a633a17558ab0c40ec21d7112c |
|
MD5 | 7216f8467d011589b6bb1ce12a8b1573 |
|
BLAKE2b-256 | 21b18aa9908e844147adef4a1c447a77e503bc912b90fa0e3434b216badf275a |
Hashes for ncollpyde-0.15.2-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b82311015cc96e03b3f53ed8113c4e36a2ee40070ff72321465466eb450a404 |
|
MD5 | 57d83916d2c7534bcd6e42fa1e5b4a46 |
|
BLAKE2b-256 | dc9c8baa27cfe4e0e94b718a71aedb0840a005d30a0fc5b1168e4fe0a19a3e14 |
Hashes for ncollpyde-0.15.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a33b90fb4b1a749857d660fa7296fe4c96753a0280029adb3603efcaba4c33c |
|
MD5 | a1f911ab162aaa9887767d97f58733af |
|
BLAKE2b-256 | 8a997c3e8c6a640a8dcd79bf7231e5c0ed60010cd00dd3c70573298214537def |