Theory of unitary spin rotation and spin-state tomography for a single electron and two electrons