NH3 trapped in nitrogen and rare gas matrices. I. Potential surface analysis