In short: How can I get a single angle along a local (body-fixed) axis from a quaternion?
In not-so-short: I am using an IMU with filtering to track the orientation of someone's upper leg. I end up with a quaternion describing the rotation from world frame to the leg frame (local frame, or body-fixed frame). But I only need a single angle from this quaternion: the swing angle (hip flexion). This is the angle around local +z (not as in the picture).
In more general terms: imagine I have an arbitrary rotation (see picture) and some local axis (the translucent blue line), how can I find the angle between the rotated frame and the original frame along this axis?
In the posted example I would expect to find about +170 degrees (sign based on right-hand rule from the selected rotation axis).