A relationship between nuclear spin relaxation in the laboratory and rotating frames for dipolar and quadrupolar relaxation