Skip to main content

Python implementation of "An efficiently computable metric for comparing polygonal shapes" (Arkin et al.)

Project description

Turning Function

This module contains Python bindings to a C-implementation of "An efficiently computable metric for comparing polygonal shapes" (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.

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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

turning_function-0.0.3-cp310-cp310-win_amd64.whl (58.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

turning_function-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (91.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

turning_function-0.0.3-cp310-cp310-macosx_10_15_universal2.whl (113.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

turning_function-0.0.3-cp39-cp39-win_amd64.whl (58.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

turning_function-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (91.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

turning_function-0.0.3-cp39-cp39-macosx_10_15_universal2.whl (113.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)

turning_function-0.0.3-cp38-cp38-win_amd64.whl (58.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

turning_function-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (91.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

turning_function-0.0.3-cp38-cp38-macosx_10_15_universal2.whl (113.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)

turning_function-0.0.3-cp37-cp37m-win_amd64.whl (59.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

turning_function-0.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

turning_function-0.0.3-cp37-cp37m-macosx_10_15_x86_64.whl (58.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

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