Projecting a UnitQuaternion on a 2D plane

I get the heading of my IMU device in space as a Quaternion [x, y, z, w]. If it’s sitting flat on the floor, it should point forward along the XY-plane. (I’m considering the floor to be the XY-plane, and positive Z to be up).

Although I get a value in 3D space, I’m only interested in the heading in the XY-plane. If I disregard the “twisting” (My mental model of a quaternion is a 3D vector, which is additionally “twisted” about its axis (roll?)), and only think about the quaternion as a 3-dimensional vector, pointing somewhere in 3D space, I should be able to project that vector onto my 2D XY-plane.

Alternatively, what I might really be after is the “yaw” component of the original quaternion represented as Euler angles. Unfortunately I didn’t find a method to convert a Quaternion to Euler angles. (I did find the other way http://nalgebra.org/rustdoc/nalgebra/geometry/type.UnitQuaternionBase.html#method.from_euler_angles)

Forgive me for not necessarily using the correct terms. Unfortunately geometry is not my strongest suit.