Expand description
§ct-sternbrocot — Stern-Brocot Constrained Pythagorean Snap
Uses Stern-Brocot descent to find the optimal Pythagorean triple for a given angle. Falls back to Euclid enumeration when SB misses.
Key insight: the Stern-Brocot tree finds best rational approximations, but mediants of Pythagorean triples aren’t always Pythagorean. This crate combines SB guidance with Euclid verification for correctness.
Structs§
- Snap
Triple - Result of a snap operation.
Functions§
- generate_
triples - Generate Pythagorean triples via Euclid’s formula.
- is_
pythagorean - Check if (a, b, c) is a valid Pythagorean triple.
- sternbrocot_
bound - Stern-Brocot optimal bound: the best possible rational approximation of tan(theta) with denominator constraint.
- sternbrocot_
snap - Stern-Brocot guided snap: use SB to narrow the search, then verify.