code: public Matrix4 setToRotation (IQuaternion quat) {
          float x = quat.x(), y = quat.y(), z = quat.z(), w = quat.w();
          float xx = x*x, yy = y*y, zz = z*z;
          float xy = x*y, xz = x*z, xw = x*w;
          float yz = y*z, yw = y*w, zw = z*w;
          return set(1f - 2f*(yy + zz), 2f*(xy - zw), 2f*(xz + yw), 0f,
                     2f*(xy + zw), 1f - 2f*(xx + zz), 2f*(yz - xw), 0f,
                     2f*(xz - yw), 2f*(yz + xw), 1f - 2f*(xx + yy), 0f,
                     0f, 0f, 0f, 1f);
      }
docs: Sets this to a rotation matrix. The formula comes from the
  <a href="http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix and Quaternion FAQ</a>.
  
  @return a reference to this matrix, for chaining.