Tools for 2D open and closed paths
Lightweight package for working with 2D paths/polygons.
import pypathlib # Create path path = pypathlib.ClosedPath([[0, 0], [0, 1], [1, 1], [1, 0]]) # Get the squared distance of some points to the path path.squared_distance([[0.5, 0.5], [0.1, 2.4]]) # Get the _signed_ squared distance of some points to the path # (negative if inside the path) path.signed_squared_distance([[0.5, 0.5], [0.1, 2.4]]) # Check if the path contains the points # (with a tolerance; set negative if you want to exclude the boundary) path.contains_points([[0.5, 0.5], [0.1, 2.4]], tol=1.0e-12)
pypathlib is fully vectorized, so it's pretty fast. (Not quite as fast as
- S.W. Sloan, A point-in-polygon program. Adv. Eng. Software, Vol 7, No. 1, pp. 45-47, 1985, 10.1016/0141-1195(85)90094-4.
pypathlib is available from the Python Package Index, so simply type
pip install -U pypathlib
to install or upgrade.
To run the pypathlib unit tests, check out this repository and type
To create a new release
publish to PyPi and GitHub:
pypathlib is published under the MIT license.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pypathlib-0.1.2-py2.py3-none-any.whl (5.8 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size pypathlib-0.1.2.tar.gz (5.7 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for pypathlib-0.1.2-py2.py3-none-any.whl