我试图让矢量的方向指向相机,相对于磁北.我的印象是我需要使用getOrientation()返回的值,但我不确定它们代表什么.当我改变手机的方向时,我从getOrientation()获得的值不会发生可预测的变化(旋转90度不会将值改变90度).我需要知道getOrientation()返回的值是什么意思.到目前为止我所写的内容如下:
package com.example.orientation;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.Toast;
public class Orientation extends Activity{
private SensorManager mSM;
private mSensorEventListener mSEL;
float[] inR = new float[16];
float[] outR= new float[16];
float[] I = new float[16];
float[] gravity = new float[3];
float[] geomag = new float[3];
float[] orientVals = new float[3];
final float pi = (float) Math.PI;
final float rad2deg = 180/pi;
/** Called when the activity is first created. */
@Override …Run Code Online (Sandbox Code Playgroud) rotation accelerometer orientation magnetometer augmented-reality