On the Hopf index theorem and the Hopf invariant