Add new code for direct quaternion integration