title: Blender bpy: Retrieve object rotation as quaternion without modifying scene
body: <p>I am writing a blender exporter for my scene format.</p>
  
  <p>When exporting, I need the rotation as quaternion.</p>
  
  <p>The easiest way I found is to use the <a href="http://www.blender.org/documentation/blender_python_api_2_71_release/bpy.types.Object.html#bpy.types.Object.rotation_mode" rel="nofollow">rotation_quaternion</a>. But this member only guarantees to store the rotation, when the <code>rotation_mode</code> is set to <code>'QUATERNION'</code>.</p>
  
  <p>My temporary solution current looks like:</p>
  
  <pre><code>prevRotationMode = object.rotation_mode
  object.rotation_mode = 'QUATERNION'
  rotationAsQuaternion = object.rotation_quaternion
  object.rotation_mode = prevRotationMode
  </code></pre>
  
  <p>This solution works, but I  am affraid this may introduce numerical errors when my exporter would be called often, as the rotation angles would be converted between quaternion representations and the original representation.</p>
  
  <p>My second idea was to copy the object, and change the rotation-mode in the copy of the object and deleting it afterwards. But this still wouldn't be a clean solution, as the scene would be modified by the exporter script.</p>
  
  <p>Is there an elegant way to get the rotation as quaternions without modifying the scene?</p>