title: Quaternion addition like 3ds/gmax does with it's quats
body: <p>A project I'm working on needs a function which mimics 3ds/gmax's quaternion addition. A test case of (quat 1 2 3 4)+(quat 3 5 7 9) should equal (quat 20 40 54 2). These quats are in xyzw.
  So, I figure it's basic algebra, given the clean numbers. It's got to be something like this multiply function, since it doesn't involve sin/cos:</p>
  
  <pre><code>    const quaternion &amp;operator *=(const quaternion &amp;q)      
      {
          float x= v.x, y= v.y, z= v.z, sn= s*q.s - v*q.v;
          v.x= y*q.v.z - z*q.v.y + s*q.v.x + x*q.s;
          v.y= z*q.v.x - x*q.v.z + s*q.v.y + y*q.s;
          v.z= x*q.v.y - y*q.v.x + s*q.v.z + z*q.s;
          s= sn;
          return *this;
      } 
  </code></pre>
  
  <p><a href="http://willperone.net/Code/quaternion.php" rel="nofollow" title="source">source</a></p>
  
  <p>But, I don't understand how sn= s*q.s - v*q.v is supposed to work. s is a float, v is vector. Multiply vectors and add to float? 
  I'm not even sure which terms of direction/rotation/orientation these values represent, but if the function satisfies the quat values above, it'll work. </p>