Hi,
while I am not an expert on quaternions, I don't think that zeroing out the x/y parts of a quaternion will return the heading - assuming that you did something like q.setX(0.0f), q.setY(0.0); q->getAngle() . If you did something different, e.g. multiplying in an inverse rotation which cancels out the x,y parts, you would have to post your code.
Just imagine a rotation around (1.0, 0.0, 0, PI/2) with X-axis=right, y=forward, z=up. This rotation has no heading component (it's just changing the pitch, i.e. the objects is pointing up), but getAngle() (after zeroing x/y) would still return PI/2 (instead of 0). Even worse: rotating around (1.0, 0, PI) would mean the object is pointing backwards (so heading is changed to 180 degrees), but upside down. So I don't think that your approach would work.
The way I have described work as expected (when using the matrix, not the quaternion, see my question in the thread) to steer a kart around a racing course
Best regards,
Joerg