Magneto-optic rotation for an arbitrary field direction