android.hardware.SensorManager.getQuaternionFromVector()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中android.hardware.SensorManager.getQuaternionFromVector()方法的一些代码示例,展示了SensorManager.getQuaternionFromVector()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SensorManager.getQuaternionFromVector()方法的具体详情如下:
包路径:android.hardware.SensorManager
类名称:SensorManager
方法名:getQuaternionFromVector

SensorManager.getQuaternionFromVector介绍

暂无

代码示例

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

private void updateOrientation() {
  float[] lastAccelerometer = mSensorData[kSensorType_Accelerometer].values;
  float[] lastMagnetometer = mSensorData[kSensorType_Magnetometer].values;
  if (lastAccelerometer != null && lastMagnetometer != null) {
    SensorManager.getRotationMatrix(mRotation, null, lastAccelerometer, lastMagnetometer);
    SensorManager.getOrientation(mRotation, mOrientation);
    final boolean kUse4Components = true;
    if (kUse4Components) {
      SensorManager.getQuaternionFromVector(mQuaternion, mOrientation);
      // Quaternions in Android are stored as [w, x, y, z], so we change it to [x, y, z, w]
      float w = mQuaternion[0];
      mQuaternion[0] = mQuaternion[1];
      mQuaternion[1] = mQuaternion[2];
      mQuaternion[2] = mQuaternion[3];
      mQuaternion[3] = w;
      mSensorData[kSensorType_Quaternion].values = mQuaternion;
    } else {
      mSensorData[kSensorType_Quaternion].values = mOrientation;
    }
  }
}

代码示例来源:origin: justasm/WindowView

switch (event.sensor.getType()) {
  case Sensor.TYPE_ROTATION_VECTOR:
    SensorManager.getQuaternionFromVector(latestQuaternion, event.values);
    if (!haveRotVecData) {
      initialiseDefaultFilters(SMOOTHING_FACTOR_HIGH_ACC);

代码示例来源:origin: apacha/sensor-fusion-demo

@Override
  public void onSensorChanged(SensorEvent event) {
    // we received a sensor event. it is a good practice to check
    // that we received the proper event
    if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
      // convert the rotation-vector to a 4x4 matrix. the matrix
      // is interpreted by Open GL as the inverse of the
      // rotation-vector, which is what we want.
      SensorManager.getRotationMatrixFromVector(currentOrientationRotationMatrix.matrix, event.values);

      // Get Quaternion
      // Calculate angle. Starting with API_18, Android will provide this value as event.values[3], but if not, we have to calculate it manually.
      SensorManager.getQuaternionFromVector(temporaryQuaternion, event.values);
      currentOrientationQuaternion.setXYZW(temporaryQuaternion[1], temporaryQuaternion[2], temporaryQuaternion[3], -temporaryQuaternion[0]);
    }
  }
}

代码示例来源:origin: apacha/sensor-fusion-demo

SensorManager.getQuaternionFromVector(temporaryQuaternion, event.values);

代码示例来源:origin: apacha/sensor-fusion-demo

SensorManager.getQuaternionFromVector(temporaryQuaternion, event.values);

代码示例来源:origin: Phantast/smartnavi

SensorManager.getQuaternionFromVector(q, event.values);

相关文章