anchor.diff:  [stem]
   ++++
   \begin{align*}
  -q_{(X,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(w,z,-y,-x)\sin\frac{θ}{2})\\
  -q_{(Y,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(-z,w,x,-y)\sin\frac{θ}{2})\\
  -q_{(Z,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(y,-x,w,-z)\sin\frac{θ}{2})\\
  +q_{(X,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(w,z,-y,-x)\sin\frac{θ}{2}\\
  +q_{(Y,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(-z,w,x,-y)\sin\frac{θ}{2}\\
  +q_{(Z,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(y,-x,w,-z)\sin\frac{θ}{2}\\
   \end{align*}
   ++++  
   
  
positive.code: [stem]
  ++++
  \begin{align*}
  q_{(X,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(w,-z,y,-x)\sin\frac{θ}{2})\\
  q_{(Y,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(z,w,-x,-y)\sin\frac{θ}{2})\\
  q_{(Z,θ)}=(x,y,z,w)\cos\frac{θ}{2}+(-y,x,w,-z)\sin\frac{θ}{2})\\
  \end{align*}
  ++++  
  
  === Appendix: Derive Quaternion Multiplication
  
  This part is not very important for understanding quaternion. It is a bit calculation heavy and is more for fun. Feel free to skip.
  
  
negative.code: 
  === Rotation along X/Y/Z Axis
  
  We can now go back to the problem I mentioned at the very beginning: we need an object to face its opposite direction. More clearly we have an object with rotation stem:[q=((x,y,z),w)], and we want to flip it along local Z axis, that is rotate it stem:[180^{\circ}] along its local Z axis. This extra rotation is denoted as stem:[q'=((0,0,\sin\frac{180^{\circ}}{2}),\cos\frac{180^{\circ}}{2})=((0,0,1),0)]. Based on local rotation composition we proved in previous section, the result is 
  
  [stem]
  ++++
  q_Z=qq'=((x,y,z),w)((0,0,1),0)=((y,-x,w),-z)
  ++++
  
  If we generalize the angle to stem:[θ], then stem:[q'=((0,0,\sin\frac{θ}{2}),\cos\frac{θ}{2})], then the result is:
  
  [stem]
  ++++
  \begin{align*}
  q_{(Z,θ)}=qq'&=((x,y,z),w)((0,0,\sin\frac{θ}{2},\cos\frac{θ}{2})\\
  &=((x,y,z),w)(((0,0,0),1)\cos\frac{θ}{2}+((0,0,1),0)\sin\frac{θ}{2})\\
  &=((x,y,z),w)\cos\frac{θ}{2}+((y,-x,w),-z)\sin\frac{θ}{2}\\
  \end{align*}
  ++++  
  
  