Solving two-point boundary value problems using generating functions: Theory and Applications to optimal control and the study of Hamiltonian dynamical systems