A Rust backed implementation for generating 2D alpha shapes from points
Project description
fast-alphashape
A Rust backed implementation for generating 2D alpha shapes from points.
Alpha shapes are often used to generalise bounding polygons containing sets of points. The alpha parameter is defined as the value a
, such that an edge of a disk of radius 1/a
can be drawn between any two edge members of a set of points and still contain all the points. The convex hull, a shape resembling what you would see if you wrapped a rubber band around pegs at all the data points, is an alpha shape where the alpha parameter is equal to zero.
Installation
pip install fast-alphashape
Quick start
The package provides an alphashape
function that takes a 2D array of points and an alpha value:
import numpy as np
from fast_alphashape import alphashape
points = np.array(
[
(0.0, 0.0),
(0.0, 1.0),
(1.0, 1.0),
(1.0, 0.0),
(0.5, 0.25),
(0.5, 0.75),
(0.25, 0.5),
(0.75, 0.5),
]
)
alpha_polygon = alphashape(points, alpha=2.0)
Development
Prequisites:
- Python (>=3.7) and make
- Rust toolchain
After cloning the repository, the Makefile includes helpful commands for setting up a development environment, linting, formatting, testing, and benchmarking. Get started as follows:
# setup a new virtual environment
python -m venv .venv
source .venv/bin/activate
# install the development dependencies
make install
# check other available commands
make help
Tooling:
- Cargo and Pytest are used for testing the Rust and Python code respectively (see
/tests
). - Python code is linted using flake8 and formatted using Black; rust code with
cargo fmt
andcargo clippy
. - pre-commit is used to run these checks locally before files are pushed to git
- The Github Actions pipeline runs these checks and tests
- Semantic-release is used with conventional commits for automated releasing to PyPI
Credits
- This project is largely a Rust port of the Alpha Shape Toolbox by Ken Bellock
- Image credit: Sigbert, CC BY-SA 3.0, via Wikimedia Commons
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 Distributions
Built Distribution
File details
Details for the file fast_alphashape-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: fast_alphashape-0.1.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24c91835492071361764e80f2508cb42b427db5ee6ea5e4ded45fddaf2c727c8 |
|
MD5 | 1b44b9f2fe78194a54340d32de63ac65 |
|
BLAKE2b-256 | 033545aed702a3e55df00061998615a667e3d18c014852a0b5aa79d71388ae72 |