title: iPhone rotation quaternion absolute coordinates?
body: <p>I have an iPhone with gyroscope.</p>
  
  <p>Let's say I have a quaternion of the phone rotation Q.</p>
  
  <p>I want to show points on screen relative of the world absolute coordinates. So with every rotation of my phone this points will be "still" in the real 3d space (sort of augmented reality). Let's say it is 4 points forming a rectangle. </p>
  
  <p>So I have created 4 points in 3d space relative to my phone screen and apply the transformation of Q to each of it. </p>
  
  <p>I thought it should be very simple but my points get transformed not relative to the world coordinates but to the something coordinates I don't understand, may be phone axis related?. Could you please help me with this? I need to create new view on the screen which will be projection from the virtual points in absolute 3d space to the rotated camera. </p>
  
  <p>My rotation results seems right as long as I am not rotating the phone along its 'normal' axis (perpendicular to screen). But rotation on that direction results in completely wrong points translation. </p>
  
  <p>Pseudocode included.</p>
  
  <p>motionManager.StartDeviceMotionUpdates </p>
  
  <pre><code>        Quaternion Q;//quaternion read from CMAttitude above, relative frame: XArbitraryZVertical
          var Qi=Q.Conjugate;
  
          var vX = new Vector3d (-1, 0, 2);
          var vY = new Vector3d (1, 0, 2);
          var vZ = new Vector3d (1, 0, -2);
          var vW = new Vector3d (-1, 0, -2);
  
          var vXn=Vector3d.Transform(vX,Qi);
          var vYn=Vector3d.Transform(vX,Qi);
          var vZn=Vector3d.Transform(vX,Qi);
          var vWn=Vector3d.Transform(vW,Qi);
  
          var convertPixels = 50;
  
          vXn = vXn * convertPixels;
          vYn = vYn * convertPixels;
          vZn = vZn * convertPixels;
          vWn = vWn * convertPixels;
  
          //screen projection
  
          X.Frame = new RectangleF (new PointF ((float)(videoArea.Width / 2 + vXn.X), (float)(videoArea.Height / 2 + vXn.Z)), new SizeF (10, 10));
          Y.Frame = new RectangleF (new PointF ((float)(videoArea.Width / 2 + vYn.X), (float)(videoArea.Height / 2 + vYn.Z)), new SizeF (10, 10));
          Z.Frame = new RectangleF (new PointF ((float)(videoArea.Width / 2 + vZn.X), (float)(videoArea.Height / 2 + vZn.Z)), new SizeF (10, 10));
          W.Frame = new RectangleF (new PointF ((float)(videoArea.Width / 2 + vWn.X), (float)(videoArea.Height / 2 + vWn.Z)), new SizeF (10, 10));
  </code></pre>