Charged particle motion in spatially varying electric and magnetic fields