[英]use of rotation vector sensor
我想實現旋轉矢量傳感器。 我盡可能多地搜索了這個傳感器,但我混淆了一些觀點。 我知道我需要使用歐拉角以外的四元數才能使我的應用程序更穩定。 我將使用此傳感器數據進行手勢識別。 所以我想使用四元數,但我不明白如何在使用remapCoordinateSystem方法后將它們轉換為四元數? 還是我對自己想做的事情有誤? 即使是一點點幫助對我來說也是非常有用的。
@Override
public void onSensorChanged(SensorEvent event) {
float[] rotationMatrix = new float[9];
SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values);
float[] adjustedRotationMatrix = new float[9];
SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Z, adjustedRotationMatrix);
float[] orientation = new float[3];
SensorManager.getOrientation(adjustedRotationMatrix, orientation);
float pitch = orientation[1];
float roll = orientation[2];
float yaw = orientation[0];
yawTextView.setText(getResources().getString(
R.string.yaw_sensor,yaw));
pitchTextView.setText(getResources().getString(
R.string.pitch_sensor,pitch));
rollTextView.setText(getResources().getString(
R.string.roll_sensor,roll));
}
謝謝你。
請參閱歐拉角到四元數的轉換。
或者,如果您想直接從旋轉矩陣計算四元數分量,請參閱此頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.