  We construct a piecewise onto 3-to-1 dynamical system on the positive
quadrant of the unit circle, such that for rational points (which correspond to
normalized Primitive Pythagorean Triples), the associated ternary expansion is
finite, and is equal to the address of the PPT on Barning's ternary tree of
PPTs, while irrational points have infinite expansions. The dynamical system is
conjugate to a modified Euclidean algorithm. The invariant measure is
identified, and the system is shown to be conservative and ergodic. We also
show, based on a result of Aaronson and Denker, that the dynamical system can
be obtained as a factor map of a cross-section of the geodesic flow on a
quotient space of the hyperbolic plane by the group $\Gamma(2)$, a free
subgroup of the modular group with two generators.
