title: Combine more than 3 rotations (Quaternions)
body: <p>I have a 3D point and the <strong>x,y,z rotations</strong> (<code>qInitial</code>) for that point.
  I want to rotate that point <strong>more</strong> (by some degrees that could be 0 up to 360) around <strong>y</strong> axis (<code>qYextra</code>). <strong>How can I calculate the final Euler rotation</strong> (<code>qResult.eulerAngles</code>) <strong>that is a combination of these 4 rotations (x-y-z-y)</strong>?</p>
  <p>I have tried calculating the initial quaternion rotation, and the extra rotation to be applied. And then multiply these two quaternions. However, I get <strong>weird results (probably gimbal lock)</strong>.</p>
  <p>Code in C#. Unity.</p>
  <p>1.<code>Quaternion qX = Quaternion.AngleAxis(rotationFromBvh.x,Vector3.right);</code></p>
  <p>2.<code>Quaternion qY = Quaternion.AngleAxis(rotationFromBvh.y,Vector3.up);</code></p>
  <p>3.<code>Quaternion qZ = Quaternion.AngleAxis(rotationFromBvh.z,Vector3.forward);</code></p>
  <p>4.<code>Quaternion qYextra = Quaternion.AngleAxis(angle,Vector3.up);</code></p>
  <p><code>Quaternion qInitial = qY * qX * qZ; // Yes. This is the correct order.</code></p>
  <blockquote>
  <p><code>qY*qX*qZ</code> has <strong>exactly the same Euler x,y,z results</strong> as
  <code>Quaternion.Euler(rotationFromBvh)</code></p>
  </blockquote>
  <p><code>Quaternion qResult = qInitial * qYextra;</code></p>
  <p><code>return qResult.eulerAngles;</code></p>
  <p>I can <strong>confirm</strong> that the <strong>code works fine</strong> (no gimbal lock) when <strong>4th rotation is 0 degrees</strong> (<code>qYextra = identity</code>). Meaning that <code>qInitial</code> is correct. So, the error might be due to the <strong>combination of those 2 rotations</strong> (<code>qInitial</code> and <code>qYextra</code>) <strong>OR</strong> due to the convertion <strong>from Quaternion to Euler</strong>.</p>
  <p><strong>EXAMPLE:</strong> (<code>qYextra</code> angle is 120 degrees)</p>
  <p><strong>RESULTS:</strong></p>
  <p><code>qInitial.eulerAngles</code> gives these results: <a href="https://i.stack.imgur.com/srkuc.png" rel="nofollow noreferrer">applying_qInitial_rotation</a></p>
  <p><code>qResult.eulerAngles</code> gives these results: <a href="https://i.stack.imgur.com/2psfU.png" rel="nofollow noreferrer">applying_qResult_rotation</a></p>
  <p><strong>EXPECTED RESULTS:</strong></p>
  <p>The expected results should be like <code>qInitial</code> but rotated 120 degrees around y.</p>
  <p>Any suggestions? I haven't yet found a solution, and probably I won't.</p>