Complex images for electrostatic field computation in multilayered media