On a class of Rellich inequalities