The least-curvature principle of Gauss and Hertz and geometric dynamics