I need to measure how much a rotation $q$ has been rotated about a given axis $\hat{a}$. $q$ in my case is a quaternion but it could be any sort of 3d rotation and I know its original orientation.
Given $q$ and an axis $\hat{a}$ is it possible to determine its relative rotation about $\hat{a}$? The only solution I Thought of so far was to pick a parallel vector to $\hat{a}$ and after the rotation project onto the plane of the axis and take the dot product with the parallel vector to determine the angle. Unfortunately, that has issues with gimbal lock. I could do a conditional to see if its projection gives a zero length vector on the plane and then pick another axis but I feel like there should be a closed form solution of the problem.