A Generalized method for calculating wake potentials