Skip to main content

Rotating calipers module

Rotating calipers is python module implementing an algorithm with the same name.

Rotating calipers algorithm

Algorithm was first invented by Michalel Shamos in 1978 and gained its name "rotating calipers" thanks to Godfried Toussant who featured it in his paper in 1983.

The method is so named because the idea is analogous to rotating a spring-loaded vernier caliper around the outside of a convex polygon. Every time one blade of the caliper lies flat against an edge of the polygon, it forms an antipodal pair with the point or edge touching the opposite blade. The complete "rotation" of the caliper around the polygon detects all antipodal pairs; the set of all pairs, viewed as a graph, forms a thrackle. The method of rotating calipers can be interpreted as the projective dual of a sweep line algorithm in which the sweep is across slopes of lines rather than across x- or y-coordinates of points.

Above description was adapted from wikipedia page: https://en.wikipedia.org/wiki/Rotating_calipers

Motivation

The "rotating calipers" algorithm was implemented by me for a university project. Suprisingly I went through a lot of trouble finding an efficient solution in python. That is why I wanted to share it with everyone who needs fast "rotating calipers" implementation in python.

Complexity

As rotating calipers runs in linear time it needs a convex hull on input wihch is calculated here using Graham's algorithm which runs in O(nlogn). All in all algorihm's (Graham's algorithm + rotating calipers) time complexity is O(nlogn) + O(n) = O(nlogn)

How to install

Linux:

  1. Open terminal
  2. Run: pip install rotating-calipers

How to use

Example of use can be found here

Metadata

Release files for rotating-calipers 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rotating-calipers 1.0
File Size Uploaded
rotating_calipers-1.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rotating-calipers 1.0
File Interpreter ABI Platform
rotating_calipers-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / rotating_calipers-1.0.tar.gz

Download URL rotating_calipers-1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ce761e67f9bcef011ba77c3790e0ccd99e2b32c156f3b291bfaa71adc7e0b48
BLAKE2b-256 checksum
How to use checksums
1f8b42f31a07af1b32a21b7c141bf0224336e6f9127bc83290c88aba56429210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Release files / rotating_calipers-1.0-py3-none-any.whl

Download URL rotating_calipers-1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84caac967d3e913fac9d63646cacd4e42706082271582bcc60e0c9632c22633d
BLAKE2b-256 checksum
How to use checksums
91f54ace5b2d3981ea5d9f29fab12cadf4554547912a909256c758cd9cccd43e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page