title: Unity c# Quaternion: Swap y with z axis
body: <p>I need to rotate an object to have an exact rotation relative to real world. Therefore calling <code>Input.gyro.attitude</code> returns a Quaternion representing the position of the device. On the other hand, this forces me to compute every rotation based upon this quaternion as default rotation. 
  An easy way to set some object facing upwards would be the following:</p>
  
  <pre><code>Vector3 up = Input.gyro.attitude.eulerAngles;
  ... 
  transform.rotation = Quaternion.Euler(up.x, up.y, up.z);
  </code></pre>
  
  <p>This rotates <code>up.z</code> around z, then <code>up.x</code> around x, and <code>up.y</code> around y.</p>
  
  <p>My problem is, that the coordinate system is not quite right, in my app the y and z axis swapped (I'm using Vuforia, so it's always relative to the marker), meaning that an rotation around z results in a rotation around y and the other way around. Here things get difficult: Obviously</p>
  
  <pre><code>transform.rotation = Quaternion.Euler(up.x, up.z, up.y);
  </code></pre>
  
  <p>fails, since this still rotates first around z, but now with <code>up.y</code>. The correct order would be to create a rotation, that rotates first around y, then x, then z. </p>
  
  <p>Since the Euler Angles are retrieved from a Quaternion,</p>
  
  <pre><code>    transform.rotation = Quaternion.identity;
      transform.Rotate(0, up.eulerAngles.z, 0);
      transform.Rotate(up.eulerAngles.x, 0, 0);
      transform.Rotate(0, 0, up.eulerAngles.y);
  </code></pre>
  
  <p>won't work either, of course.</p>
  
  <p>However, I can't find a way to do this. Am I overlooking something? </p>