The analysis of spin and spin-orbit coupling in quantum and classical physics by quaternions