在这里,我将我开发的代码用于移动手机的旋转。使用Android API Rotation_vector_type == quaternion进行数据搜索 谢谢。
while (fscanf(f, "%lf %lf %lf %lf", &val1, &val2, &val3, &val4)!=EOF)
{
cont++;
b.x = val1;
b.y = val2;
b.z = val3;
b.w = val4;
quaternion rez;
rez.w = newRotation.w * b.w - newRotation.x * b.x - newRotation.y * b.y - newRotation.z * b.z; // 1
rez.x = newRotation.w * b.x + newRotation.x * b.w + newRotation.y * b.z - newRotation.z * b.y; // i
rez.y = newRotation.w * b.y - newRotation.x * b.z + newRotation.y * b.w + newRotation.z * b.x; // j
rez.z = newRotation.w * b.z + newRotation.x * b.y - newRotation.y * b.x + newRotation.z * b.w; // k
newRotation = rez;
}
cout << newRotation.x << " " << newRotation.y << " " << newRotation.z << " " << newRotation.w << endl;