High-latitude electric fields and the three-dimensional interaction between the interplanetary and terrestrial magnetic fields