A fast and simple method for calculating electrostatic potentials