Geometric formulation of Carnot's theorem