https://github.com/dbraun/turning-function
Python module of "An efficiently computable metric for comparing polygonal shapes" (Arkin et al.)
https://github.com/dbraun/turning-function
Last synced: 9 months ago
JSON representation
Python module of "An efficiently computable metric for comparing polygonal shapes" (Arkin et al.)
- Host: GitHub
- URL: https://github.com/dbraun/turning-function
- Owner: DBraun
- Created: 2022-06-15T21:45:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-17T03:05:13.000Z (over 3 years ago)
- Last Synced: 2025-03-29T03:51:14.934Z (10 months ago)
- Language: C
- Homepage:
- Size: 28.3 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Turning Function
This module contains Python bindings to a C-implementation of ["An efficiently computable metric for comparing polygonal shapes"](http://www.cs.cornell.edu/~dph/papers/ACHKM-TPAMI-91.pdf) (Arkin et al., 1991).
## Installation
`pip install turning_function`
## Usage
Call `turning_function.distance(shape_a, shape_b, brute_force_updates=False)` where `shape_a`/`shape_b` are Nx2-shaped lists of points (not numpy arrays). This function will return four values: `distance, theta, ht_err, slope_err`. The error terms will be zero if `brute_force_updates` is `False`. Note that there is a maximum number of points (`turning_function.max_points`) a shape can hold.
```python
import turning_function
import random
def random_shape(num_points: int):
return [(random.random(), random.random()) for _ in range(num_points)]
shape_a = random_shape(turning_function.max_points)
shape_b = random_shape(42)
distance, theta, ht_err, slope_err = turning_function.distance(shape_a, shape_b, brute_force_updates=False)
print('Distance: ', distance)
```
## License
The original source has this disclaimer:
> Implementation (c) Eugene K. Ressler 91, 92 This source may be freely distributed and used for non-commercial purposes, so long as this comment is attached to any code copied or derived from it.