标签: react-native-sensors

在给定 (x,y,z) 陀螺仪的情况下,如何检测设备是否旋转了 360 度?

我正在使用react-native-sensor从传感器获取原始数据。

setUpdateIntervalForType(SensorTypes.gyroscope, 100)

gyroscope.subscribe(({ x, y, z, timestamp }) => {
  let pitch = Math.atan2(-x, -z) * 180 / Math.PI;// In degrees
  let roll = Math.atan2(-y, -x) * 180 / Math.PI;// In degrees
  let yaw = Math.atan2(y, -z) * 180 / Math.PI;// In degrees
  
  this.setState({pitch: pitch, roll: roll, yaw: yaw})
})
Run Code Online (Sandbox Code Playgroud)

我怎么知道设备被旋转了 360

javascript react-native react-native-sensors

3
推荐指数
1
解决办法
309
查看次数