Calculating atomic charges in molecules and crystals by a new electronegativity equalization method