Skip to main content

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://img.shields.io/travis/clbarnes/ncollpyde.svg :target: https://travis-ci.org/clbarnes/ncollpyde

.. 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

Features

  • Checking whether points are inside a volume defined by a triangular 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["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)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ncollpyde-0.7.4_alpha.0.tar.gz (255.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ncollpyde-0.7.4_alpha.0-cp38-cp38-manylinux1_x86_64.whl (244.7 kB view details)

Uploaded CPython 3.8

ncollpyde-0.7.4_alpha.0-cp37-cp37m-manylinux1_x86_64.whl (244.7 kB view details)

Uploaded CPython 3.7m

File details

Details for the file ncollpyde-0.7.4_alpha.0.tar.gz.

File metadata

  • Download URL: ncollpyde-0.7.4_alpha.0.tar.gz
  • Upload date:
  • Size: 255.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.8.1

File hashes

Hashes for ncollpyde-0.7.4_alpha.0.tar.gz
Algorithm Hash digest
SHA256 0a0971d87baa1cc1aa6db0eeae9058f3c78deb376804b63218e642e172ef853d
MD5 2a331d2c3a7f781fec57a15de01e9969
BLAKE2b-256 b7ff9abfdf05025c9ef6315b88d0e74ed1b2d4ab20193c10d309fa5729a4c9d1

See more details on using hashes here.

File details

Details for the file ncollpyde-0.7.4_alpha.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for ncollpyde-0.7.4_alpha.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e859e4005ce2e427ad7a3642579c257e4dd8a9b02f26ebf22a369d8a630eed92
MD5 888d87381cd23186c31b0f69c84ad148
BLAKE2b-256 39c8d816f3634b31ec6b4fa5598cb5926387631b92fd2f88f3d5a3d40aa491bd

See more details on using hashes here.

File details

Details for the file ncollpyde-0.7.4_alpha.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for ncollpyde-0.7.4_alpha.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7b3d615417b1917cc20a7e8d0e636331b92791bd10d2754645978952fc428405
MD5 d1a2c8d9f4a047f5cf05f70d8bee137a
BLAKE2b-256 9a0bf1e87ebcf7c9e7b1250787e6465b18f250c011af40c4bc8e1851007a1853

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page