Large-angle production of charged pions by 3 GeV/c-12 GeV/c protons on carbon, copper and tin targets