O(log n) nearest-neighbor search on the full-circle Pythagorean manifold — zero drift, 1000x+ speedup
Project description
pythagorean-snap
O(log n) nearest-neighbor search on the full-circle Pythagorean manifold — zero drift, 1000x+ faster than brute force.
Install
pip install pythagorean-snap
Quick Start
from pythagorean_snap import PythagoreanManifold
m = PythagoreanManifold(50_000)
t = m.snap_angle(0.785) # snap to nearest triple at ~45°
print(f"({t.x}, {t.y}, {t.c}) — angle: {t.angle():.4f} rad")
assert t.verify() # x² + y² = c² — always exact
Performance
At max_c = 50,000 (41K+ triples):
- Binary search: O(log n) per query
- 100% agreement with brute-force
- Zero floating-point drift
API
| Method | Description |
|---|---|
PythagoreanManifold(max_c) |
Build manifold |
.snap_angle(theta) |
Nearest triple to angle (rad) |
.snap_brute(theta) |
Brute-force (verification) |
.constraint_distance(theta) |
Angular distance |
.angle_range() |
(min, max) angle |
.iter_triples() |
Iterate all triples |
License
MIT
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pythagorean_snap-0.1.0.tar.gz.
File metadata
- Download URL: pythagorean_snap-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4d65e0c5f77f56abf4b96fc50d2e6cf76d1e9757bee6672be671dc9f40ea67
|
|
| MD5 |
f8403e776c1add2833af84cefdcfbdd6
|
|
| BLAKE2b-256 |
b8811c7792a8e7f4989c50b6fa9c64431d2f6c3b8f6fb0dbdc44aa2d03afbb17
|
File details
Details for the file pythagorean_snap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pythagorean_snap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd91eb836caa40d6bbfbe388b94181d42c2321defc5f2f3e56b5ca6b6aca569c
|
|
| MD5 |
eabdd6d63a707ec4076edc791242ce56
|
|
| BLAKE2b-256 |
738f2210ba17e8e30a78346404e84ea2b6577ec4b302a926f6adc9fe6c7b7889
|