title: Constant Rotation of a SceneKit Model
body: <p>I'm getting accelerometer data 10x/second from an external device and I want to have that be reflected on a 3-D SceneKit model. That is, I want the model to rotate in response to the accelerometer data. The 3-D model is a .dae file built in SketchUp that I'm loading into the SceneKit scene.</p>
  
  <p>I'm currently trying to make a rotation on the SceneKit scene's root node (here <code>self</code> refers to a custom <code>SCNView</code> class):</p>
  
  <p><code>self.scene.rootNode.transform = CATransform3DMakeRotation(angle, x, y, z);</code></p>
  
  <p>There's a couple problems with this:</p>
  
  <ul>
  <li>It's not rotating a specific amount along each axis, it's rotating a fixed amount along a certain vector. Is it possible to manipulate how many degrees a certain axis rotates by changing the relative vector values? Would it make sense to implement a transform with three <code>CATransform3DRotate</code>s, one for each axis?</li>
  <li>It creates a new rotation every time instead of only rotating the difference in angles from the last reading. For example, if the accel data was <code>x: 60˚, y: 40˚, y: -30˚</code> last reading and is now <code>x: 65˚, y: 45˚, y: -35˚</code>, the model will rotate the full 65˚ along the x-axis, not just the 5˚ difference from last time (as it should). This seems easily fixable by subtracting the last reading from the current reading, but I'm not sure how the math works out with the rotation.</li>
  </ul>