Control, Optimisation and Calculus of Variations