home/ atoms/ pythagorean-triplet-rotation

Pythagorean integer triplets provide exact normalized rotation matrices without trigonometry

A 2D rotation matrix requires cos(θ) and sin(θ) as entries with the constraint cos²+sin²=1. Any Pythagorean triple (a,b,c) with a²+b²=c² satisfies this: dividing by c gives (a/c, b/c) which are exact normalized values. For example (3,4,5): cos=3/5=0.6, sin=4/5=0.8, giving a ~53° rotation. These integers avoid floating-point precision loss from trigonometry, and the rotation is guaranteed unit-length. IQ uses them for static rotations (eyebrow tilt, eyelid angle) where an exact angle is not needed — just a natural-looking tilt.

Examples

mat2 rot35 = mat2(3,4,-4,3)/5.0; // ~53° rotation, exact

Assessment

Construct the rotation matrix from the triplet (5,12,13) and verify that the two column vectors are orthogonal and unit-length.

“Pythagorean triplets, right? Which means, you know, Pythagoras, the theorem, right rectangles, like, side three, side four, hypotenuse is side five”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 10