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
manylinux-compatible wheels are built on CI but not necessarily in your local environment. Always allow CI to deploy the wheels.
If you are installing from a source distribution rather than a wheel, you need a compatible rust toolchain
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.17.0-cp36-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57ee0aff021db5fc5844ad0ee9f4c3aa964273e5003e57c8ad2827ac71598083 |
|
MD5 | e06569c9bd00367f25227dfb1f29073f |
|
BLAKE2b-256 | ba791620b1c0cde6603cdf1739461157fad92cd6722966cbe1f503b34a16f2fa |
Hashes for ncollpyde-0.17.0-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba75416eaef502095ef89c1fb921cff72738b5360fa8942b9f9366f4990a7169 |
|
MD5 | 38d19611c67d1194f000c9cf868a4ea3 |
|
BLAKE2b-256 | 6541d83054de61dd7f7a7bbb73939657fee96bb49f6cc668e792af7372ded65a |
Hashes for ncollpyde-0.17.0-cp36-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47cb202a5ac6d1268ec0b7c33443435704d095577242e04246718d4e0aa83d8f |
|
MD5 | 8f944953f883fb7769933fe336ca89c1 |
|
BLAKE2b-256 | 1fa39ddf402dbb35b4a0b8660da03a57619a9ea17f3090f9ff4b0e0dcc1658cf |