title: Please help me correctly apply device rotation data
body: <p>So I have a bit of a project I am trying to do. I am trying to get the devices rotation relative to gravity, and translation from where it started.  So basically getting "tracking" data for the device.  I plan to basically apply this by making a 3d pt that will mimic the data I record from the device later on.</p>
  
  <p>Anyway to attempt to achieve this I thought it would be best to work with scene kit that way I can see things in 3 dimensions just like the data I am trying to record.  Right now I have been trying to get the ship to rotate so that it always looks like its following gravity (like its on the ground or something) no mater what the device rotation is.  I figure once I have this down it will be a sinch to apply this to a point.  So I made the following code:</p>
  
  <pre><code>if let attitude = motionManager.deviceMotion?.attitude {
          print(attitude)
  
  
          ship.eulerAngles.y = -Float(attitude.roll)
          ship.eulerAngles.z = -Float(attitude.yaw)
          ship.eulerAngles.x = -Float(attitude.pitch)
  
      }
  </code></pre>
  
  <p>When you only run one of the rotation lines then everything is perfectly.  It does behave properly on that axis.  However when I do all three axis' at once it becomes chaotic and performs far from expected with jitter and everything.</p>
  
  <p>I guess my question is: 
  Does anyone know how to fix my code above so that the ship properly stays "upright" no matter what the orientation.</p>