나는 장치 하드웨어 (나침반, 가속도계)은 가속도계를 사용하여 안정적인 방위
다음 가이드 아름답다고를 사용하여 3D 오브젝트를 회전하는 방법에 주변에 사냥 한을 받고 : http://ibuzzlog.blogspot.co.uk/2012/08/how-to-use-android-sensors.html?showComment=1409868331799#c665801926070707020
그러나 방위각을 여러 장치에서 놀라운 점프입니다.
이 http://blog.thomnichols.org/2011/08/smoothing-sensor-data-with-a-low-pass-filter
업데이트를 트릭을 할 것 같다 그이 찾을 수
@Override
public void onSensorChanged(SensorEvent event) {
int type = event.sensor.getType();
//Log.i("TAG", "Sensor " + type);
if(event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
{
MagneticFieldValues_last[0] = event.values[0];
MagneticFieldValues_last[1] = event.values[1];
MagneticFieldValues_last[2] = event.values[2];
bHaveMagneticField = true;
}
if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
{
AccelerometerValues_last[0] = event.values[0];
AccelerometerValues_last[1] = event.values[1];
AccelerometerValues_last[2] = event.values[2];
bHaveAccelerometer = true;
}
if(bHaveMagneticField && bHaveAccelerometer)
{
if(SensorManager.getRotationMatrix(R, null, AccelerometerValues_last, MagneticFieldValues_last))
{
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, remapR);
SensorManager.getOrientation(remapR, orientationValues);
Matrix.multiplyMV(orientationVector, 0, remapR, 0, sZVector, 0);
pitch2 = (float) (-Math.atan2(orientationVector[1], orientationVector[2]) * RADIANS_TO_DEGREES);
Matrix.multiplyMV(orientationVector, 0, remapR, 0, sZVector, 0);
orientation = (float) (-Math.atan2(orientationVector[0], orientationVector[1]) * RADIANS_TO_DEGREES);
Matrix.invertM(remapR_inv, 0, remapR, 0);
Matrix.multiplyMV(azimuthVector, 0, remapR_inv, 0, sZVector, 0);
azimuth = (float) (180 + Math.atan2(azimuthVector[0], azimuthVector[1]) * RADIANS_TO_DEGREES);
}
}
}
UPDATE (이, 당신의 얼굴에 묶여 있었다 상상 찾고 왼쪽 및 오른쪽)이
슬프게도 트릭을하지는 않지만 여전히 가치를 매끄럽게하는 방법이 필요합니다. 어떻게 다른 사람들이 이것을합니까?