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.
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.16.0-cp36-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28142521c7b1c6cca6cb23683980c4c3c5cd078f20e0b46c3f65d5472534f944 |
|
MD5 | 22253cc2ba073fffa7a371e16ec4cc46 |
|
BLAKE2b-256 | 78ba58b1b8f03cc54bf61ee8328c8531840b19c3d0fd1085c30ef25599ac1d37 |
Hashes for ncollpyde-0.16.0-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ff8a40bfaa7db2cc3363d383528a5ed53a0a1b88cfefdff6d220ff90af3fa8 |
|
MD5 | 8f7b5bdc5548984468a97cfcf9730b41 |
|
BLAKE2b-256 | 3b1ffe19fc94b8016d17ba3ab8ce20ba70e0f8bd58f4778425b23d8600b6bfbb |
Hashes for ncollpyde-0.16.0-cp36-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d0b14af6592d3750dc07e8d2dcb590ad4384b636ea7cccf1efaf6c2d10e7db |
|
MD5 | 3bec2bc0696a769d1a15c9466712dcf2 |
|
BLAKE2b-256 | d0c18851401cccc2f08079e490bfd2a692a571990683be115f5316d6ebc01591 |