Matrix3x3 Quaternion::transformToMatrix3x3() const { Matrix3x3 result; result.setXX(1.0 - 2*(getY()*getY() + getZ()*getZ())); result.setXY(2*(getX()*getY() + getZ()*getW())); result.setXZ(2*(getX()*getZ() - getY()*getW())); result.setYX(2*(getX()*getY() - getZ()*getW())); result.setYY(1.0 - 2*(getX()*getX() + getZ()*getZ())); result.setYZ(2*(getZ()*getY() + getX()*getW())); result.setZX(2*(getX()*getZ() + getY()*getW())); result.setZY(2*(getY()*getZ() - getX()*getW())); result.setZZ(1.0 - 2*(getX()*getX() + getY()*getY())); return result; }