Forward Modeling and Inversion of 3D Electromagnetic Scattering Problems in Complicated Backgrounds