main
Yogi 2024-12-04 21:14:18 +08:00
parent 872ce15ab4
commit 04224a791b
1 changed files with 2 additions and 2 deletions

View File

@ -104,7 +104,7 @@ public class GameManager : MonoBehaviour
// 计算角速度的变化(可以设定角速度的阈值或限制其过快变化) // 计算角速度的变化(可以设定角速度的阈值或限制其过快变化)
angleX += gx * dt; // 绕X轴旋转 angleX += gx * dt; // 绕X轴旋转
angleY += gy * dt; // 绕Y轴旋转 angleY += gy * dt; // 绕Y轴旋转
angleZ += gz * dt; // 绕Z轴旋转 angleZ -= gz * dt; // 绕Z轴旋转
// 使用互补滤波来平滑姿态估计 // 使用互补滤波来平滑姿态估计
// 这里的系数决定了加速度和陀螺仪的权重通常设置为0.98 // 这里的系数决定了加速度和陀螺仪的权重通常设置为0.98
@ -118,7 +118,7 @@ public class GameManager : MonoBehaviour
brainTrans.rotation = Quaternion.Euler(new Vector3(filteredRoll, filteredPitch, angleZ)); brainTrans.rotation = Quaternion.Euler(new Vector3(filteredRoll, filteredPitch, angleZ));
break; break;
case AxisArr.XZY: case AxisArr.XZY:
brainTrans.rotation = Quaternion.Euler(new Vector3(filteredRoll, -angleZ, filteredPitch)); brainTrans.rotation = Quaternion.Euler(new Vector3(filteredRoll, angleZ, filteredPitch));
break; break;
default: default:
break; break;