Sensor.TYPE_ORIENTATION
public voID onSensorChanged(SensorEvent event){ if(event.sensor.getType() == Sensor.TYPE_ORIENTATION) { newAzimuth = (event.values[0] + 360)%360; azimuth = (float) ((newAzimuth * kFilteringFactor) + (azimuth * (1.0 - kFilteringFactor))); }}
Sensor.TYPE_MAGNETIC_FIELD
public voID onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_MAGNETIC_FIELD: mags = event.values.clone(); break; case Sensor.TYPE_ACCELEROMETER: accels = event.values.clone(); break; } if (mags != null && accels != null) { SensorManager.getRotationMatrix(R,I,accels,mags); SensorManager.remapCoordinateSystem(R,SensorManager.AXIS_X,SensorManager.AXIS_Z,remappedR); SensorManager.getorIEntation(remappedR,orIEntation); newAzimuth = (float) Math.round(Math.todegrees(orIEntation[0])); newAzimuth = (newAzimuth + 360)%360; azimuth = (float) (newAzimuth * kFilteringFactor) + (azimuth * (1.0f - kFilteringFactor)); }}解决方法 仅在使用SensorManager.DELAY_FASTER时才会发生.使用SensorManager.SENSOR_DELAY_GAME,值更稳定…… 总结
以上是内存溢出为你收集整理的android – 使用Sensor.TYPE_MAGNETIC_FIELD找到的Azimuth比Sensor.TYPE_ORIENTATION更不稳定全部内容,希望文章能够帮你解决android – 使用Sensor.TYPE_MAGNETIC_FIELD找到的Azimuth比Sensor.TYPE_ORIENTATION更不稳定所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)