ncollpyde


Namencollpyde JSON
Version 0.19.0 PyPI version JSON
download
home_pageNone
SummaryA python wrapper around a subset of the ncollide rust library
upload_time2022-04-11 14:24:36
maintainerNone
docs_urlNone
authorChris L. Barnes <chrislloydbarnes@gmail.com>
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========
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.yaml/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 library for spatial queries of points and line segments with meshes.
ncollpyde wraps around a subset of the parry rust library (formerly its predecessor ncollide).


* 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
* Get the (signed) distance from points to the boundary of a mesh

Usage
-----

This library implements most of its functionality through the ``Volume`` class,
instantiated from an array of vertices,
and an array of triangles as indices into the vertex array.

.. code-block:: python

    # get an array of vertices and triangles which refer to those points
    import meshio
    mesh = meshio.read("meshes/teapot.stl")

    # use this library
    from ncollpyde import Volume

    volume = Volume(mesh.points, mesh.cells_dict["triangle"])

    # or, for convenience
    volume = Volume.from_meshio(mesh)

    # containment checks: singular and multiple
    assert [-2.30, -4.15,  1.90] in volume
    assert np.array_equal(
        volume.contains(
            [
                [-2.30, -4.15, 1.90],
                [-0.35, -0.51, 7.61],
            ]
        ),
        [True, False]
    )

    # line segment intersection
    seg_idxs, intersections, is_backface = volume.intersections(
        [[-10, -10, -10], [0, 0, 3], [10, 10, 10]],
        [[0, 0, 3], [10, 10, 10], [20, 20, 20]],
    )
    assert np.array_equal(seg_idxs, [0, 1])  # idx 2 does not intersect
    assert np.array_equal(seg_idxs, [0, 1])
    assert np.allclose(
        intersections,
        [
            [-2.23347309, -2.23347309, 0.09648498],
            [ 3.36591285, 3.36591285, 5.356139],
        ],
    )
    assert np.array_equal(
        is_backface,
        [False, True],
    )

    # distance from boundary (negative means internal)
    assert np.array_equal(
        volume.distance([[10, 10, 10], [0, 0, 3]]),
        [10.08592464, -2.99951118],
    )

See the API docs for more advanced usage.

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
* 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 <https://www.rust-lang.org/tools/install>`_
* Meshes with >= ~4.3bn vertices are not supported, as the underlying library uses u32 to address them. This is probably not a problem at time of writing; such a mesh would take up hundreds of GB of RAM to operate on.

ncollpyde v0.11 was the last to support ``meshio < 4.0``.

Acknowledgements
----------------

Thanks to top users
`Philipp Schlegel <https://github.com/schlegelp/>`_ (check out `navis <https://github.com/navis-org/navis>`_!)
and `Nik Drummond <https://github.com/nikdrummond>`_
for their help in debugging and expanding ``ncollpyde`` 's functionality.

Thanks also to ``pyo3``/ ``maturin`` developers
`@konstin <https://github.com/konstin>`_
and `@messense <https://github.com/messense/>`_
for taking an interest in the project and helping along the way.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ncollpyde",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chris L. Barnes <chrislloydbarnes@gmail.com>",
    "author_email": "Chris L. Barnes <chrislloydbarnes@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/45/6c/fcbdd0bb2e29b5745adf4248f98cb1c54008f15a78c9a7ce305bb50401b8/ncollpyde-0.19.0.tar.gz",
    "platform": null,
    "description": "=========\nncollpyde\n=========\n\n\n.. image:: https://img.shields.io/pypi/v/ncollpyde.svg\n    :target: https://pypi.python.org/pypi/ncollpyde\n\n.. image:: https://github.com/clbarnes/ncollpyde/workflows/.github/workflows/ci.yaml/badge.svg\n    :target: https://github.com/clbarnes/ncollpyde/actions\n    :alt: Actions Status\n\n.. image:: https://readthedocs.org/projects/ncollpyde/badge/?version=latest\n    :target: https://ncollpyde.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/ambv/black\n\n\nA python library for spatial queries of points and line segments with meshes.\nncollpyde wraps around a subset of the parry rust library (formerly its predecessor ncollide).\n\n\n* Free software: MIT License\n* Documentation: https://ncollpyde.readthedocs.io.\n\nInstall\n-------\n\n``pip install ncollpyde``\n\nPre-built wheels are available for Linux, MacOS, and Windows.\nIf you have a stable rust compiler, you should also be able to install from source.\n\nFeatures\n--------\n\n* Checking whether points are inside a volume defined by a triangular mesh\n* Checking the intersection of line segments with the mesh\n* Get the (signed) distance from points to the boundary of a mesh\n\nUsage\n-----\n\nThis library implements most of its functionality through the ``Volume`` class,\ninstantiated from an array of vertices,\nand an array of triangles as indices into the vertex array.\n\n.. code-block:: python\n\n    # get an array of vertices and triangles which refer to those points\n    import meshio\n    mesh = meshio.read(\"meshes/teapot.stl\")\n\n    # use this library\n    from ncollpyde import Volume\n\n    volume = Volume(mesh.points, mesh.cells_dict[\"triangle\"])\n\n    # or, for convenience\n    volume = Volume.from_meshio(mesh)\n\n    # containment checks: singular and multiple\n    assert [-2.30, -4.15,  1.90] in volume\n    assert np.array_equal(\n        volume.contains(\n            [\n                [-2.30, -4.15, 1.90],\n                [-0.35, -0.51, 7.61],\n            ]\n        ),\n        [True, False]\n    )\n\n    # line segment intersection\n    seg_idxs, intersections, is_backface = volume.intersections(\n        [[-10, -10, -10], [0, 0, 3], [10, 10, 10]],\n        [[0, 0, 3], [10, 10, 10], [20, 20, 20]],\n    )\n    assert np.array_equal(seg_idxs, [0, 1])  # idx 2 does not intersect\n    assert np.array_equal(seg_idxs, [0, 1])\n    assert np.allclose(\n        intersections,\n        [\n            [-2.23347309, -2.23347309, 0.09648498],\n            [ 3.36591285, 3.36591285, 5.356139],\n        ],\n    )\n    assert np.array_equal(\n        is_backface,\n        [False, True],\n    )\n\n    # distance from boundary (negative means internal)\n    assert np.array_equal(\n        volume.distance([[10, 10, 10], [0, 0, 3]]),\n        [10.08592464, -2.99951118],\n    )\n\nSee the API docs for more advanced usage.\n\nKnown issues\n------------\n\n* Performance gains for multi-threaded queries are underwhelming, especially for ray intersections: see `this issue <https://github.com/clbarnes/ncollpyde/issues/12>`_\n* Very rare false positives for containment\n   * Due to a `bug in the underlying library <https://github.com/rustsim/ncollide/issues/335>`_\n   * Only happens when the point is outside the mesh and fires a ray which touches a single edge or vertex of the mesh.\n   * Also affects ``is_backface`` result for ray intersection checks\n* manylinux-compatible wheels are built on CI but not necessarily in your local environment. Always allow CI to deploy the wheels.\n* If you are installing from a source distribution rather than a wheel, you need a compatible `rust toolchain <https://www.rust-lang.org/tools/install>`_\n* Meshes with >= ~4.3bn vertices are not supported, as the underlying library uses u32 to address them. This is probably not a problem at time of writing; such a mesh would take up hundreds of GB of RAM to operate on.\n\nncollpyde v0.11 was the last to support ``meshio < 4.0``.\n\nAcknowledgements\n----------------\n\nThanks to top users\n`Philipp Schlegel <https://github.com/schlegelp/>`_ (check out `navis <https://github.com/navis-org/navis>`_!)\nand `Nik Drummond <https://github.com/nikdrummond>`_\nfor their help in debugging and expanding ``ncollpyde`` 's functionality.\n\nThanks also to ``pyo3``/ ``maturin`` developers\n`@konstin <https://github.com/konstin>`_\nand `@messense <https://github.com/messense/>`_\nfor taking an interest in the project and helping along the way.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A python wrapper around a subset of the ncollide rust library",
    "version": "0.19.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "75a3b89736d889380317d575e1183d4f611821ebbcaca0b15617850a3431939c",
                "md5": "d4a2e84a28de36a5c5e7960eaba81c7d",
                "sha256": "e00d12ac0e682b5700a432f55eff392ab885aa29927e4d7a786fd40e2b58c6a6"
            },
            "downloads": -1,
            "filename": "ncollpyde-0.19.0-cp36-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "d4a2e84a28de36a5c5e7960eaba81c7d",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": ">=3.6",
            "size": 540082,
            "upload_time": "2022-04-11T14:28:08",
            "upload_time_iso_8601": "2022-04-11T14:28:08.179197Z",
            "url": "https://files.pythonhosted.org/packages/75/a3/b89736d889380317d575e1183d4f611821ebbcaca0b15617850a3431939c/ncollpyde-0.19.0-cp36-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ecc62cf06a369079717b948e53940404a62f2d2408cd8d5424ff9e876b0213c0",
                "md5": "cb0d8105d5ca47e3b45d04425428eae2",
                "sha256": "44dcf09e1bf1182545028f4fe9ced92cca876312e8880b6b722bf28b1dca0098"
            },
            "downloads": -1,
            "filename": "ncollpyde-0.19.0-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "cb0d8105d5ca47e3b45d04425428eae2",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": ">=3.6",
            "size": 316087,
            "upload_time": "2022-04-11T14:24:35",
            "upload_time_iso_8601": "2022-04-11T14:24:35.214569Z",
            "url": "https://files.pythonhosted.org/packages/ec/c6/2cf06a369079717b948e53940404a62f2d2408cd8d5424ff9e876b0213c0/ncollpyde-0.19.0-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "18c4f81dd1b9afe6374cd5bd1c36fc2aa8679c7d12c9d98d99465242dc8bc866",
                "md5": "e4caf0b08c954e8559002dfe7f2d1a3d",
                "sha256": "061a8c443c431d9f7497f3a7ee6bbb07ca10694f561c6afb0ab2a5669fc4845b"
            },
            "downloads": -1,
            "filename": "ncollpyde-0.19.0-cp36-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "e4caf0b08c954e8559002dfe7f2d1a3d",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": ">=3.6",
            "size": 240219,
            "upload_time": "2022-04-11T14:27:03",
            "upload_time_iso_8601": "2022-04-11T14:27:03.630792Z",
            "url": "https://files.pythonhosted.org/packages/18/c4/f81dd1b9afe6374cd5bd1c36fc2aa8679c7d12c9d98d99465242dc8bc866/ncollpyde-0.19.0-cp36-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "456cfcbdd0bb2e29b5745adf4248f98cb1c54008f15a78c9a7ce305bb50401b8",
                "md5": "46028d5fb2a7ff323a3d49f5aac8e7f2",
                "sha256": "c37db9c8602075c71446716649e1818a3316bf1803cfde4d9b6a7fdbecc8899e"
            },
            "downloads": -1,
            "filename": "ncollpyde-0.19.0.tar.gz",
            "has_sig": false,
            "md5_digest": "46028d5fb2a7ff323a3d49f5aac8e7f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 262194,
            "upload_time": "2022-04-11T14:24:36",
            "upload_time_iso_8601": "2022-04-11T14:24:36.958125Z",
            "url": "https://files.pythonhosted.org/packages/45/6c/fcbdd0bb2e29b5745adf4248f98cb1c54008f15a78c9a7ce305bb50401b8/ncollpyde-0.19.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-04-11 14:24:36",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ncollpyde"
}
        
Elapsed time: 0.09327s