Fixed quaternion averaging and implementation in paintGrid