Hamiltonian Theory of Moving Interferometers for Light and Matter Waves