title: Is there a way to convert a quaternion to angles?
body: <p>I have a (world) matrix, and it applies translation, rotation and scale into an 3D object. It is created with the function <code>XMMatrixTransformation</code> (DirectXMath) and the parameter <code>RotationQuaternion</code> is made by a call to <code>XMQuaternionRotationRollPitchYaw</code>. Then it is stored in a file along with other data.  </p>
  
  <p>Then I need to recover the values, so I can use this function to decompose it to each component:</p>
  
  <pre><code>XMMatrixDecompose(&amp;Scale, &amp;RotationQ, &amp;Translation, Matrix);
  </code></pre>
  
  <p>Scale and translation are vectors and rotation is a quaternion. If the matrix rotates the object in a single axis I could use this to convert the quaternion back to the angles:</p>
  
  <pre><code>XMQuaternionToAxisAngle(&amp;Axis, &amp;Angle, RotationQ);
  </code></pre>
  
  <p>It works fine. But when it rotates in two or more axes how can I do the same? Is there a way to do that?</p>
  
  <p>PS: I don't care if the output angles aren't the same as the input. They just need to be equivalent.</p>
  
  <p>PS2: Okay, so I followed Gene's link (I had already looked there but didn't found what I needed that time). I made this code based in this equation I found in Wikipedia:
  <img src="https://upload.wikimedia.org/math/a/2/9/a2925987257bc7469187cfc3c18da853.png" alt="equation"></p>
  
  <pre><code>float Roll = atan2(2.0*(F.x*F.y + F.z*F.w), 1 - 2 * (F.y*F.y + F.z*F.z));
  float Pitch = asin(2.0*(F.x*F.z - F.w*F.y));
  float Yaw = atan2(2.0*(F.x*F.w + F.y*F.z), 1 - 2 * (F.y*F.y + F.z*F.z));
  </code></pre>
  
  <p>In the output I have different angles. The output seems to be equivalent for <code>(90°, 0°, 90°)</code>, but not for <code>(45°, 45°, 45°)</code>.</p>