2015-10-12 160 views
0

我想从这个网站适应低通滤波器: Low Pass Filter低通滤波器的Android

我的问题是,我不知道什么是以下行的目标:

int rotation = Compatibility.getRotation(this); 

我已经搜索了很多,以搜索有关此信息,但没有运气。任何人都知道它做了什么?

请参见下面的代码段:

@Override 
public void onSensorChanged(SensorEvent evt) { 
    if (evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { 
     gravSensorVals = lowPass(evt.values.clone(), gravSensorVals); 
    } else if (evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { 
     magSensorVals = lowPass(evt.values.clone(), magSensorVals); 
    } 
    if (gravSensorVals != null && magSensorVals != null) { 
     SensorManager.getRotationMatrix(RTmp, I, gravSensorVals, magSensorVals); 
     int rotation = Compatibility.getRotation(this); 
     if (rotation == 1) { 
      SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z, Rot); 
     } else { 
      SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_Z, Rot); 
     } 
     SensorManager.getOrientation(Rot, results); 
     UIARView.azimuth = (float)(((results[0]*180)/Math.PI)+180); 
     UIARView.pitch = (float)(((results[1]*180/Math.PI))+90); 
     UIARView.roll = (float)(((results[2]*180/Math.PI))); 
     radarMarkerView.postInvalidate(); 
    } 
} 

回答

1

从Android文档:here,它将检查设备取向。所以一个值是ROTATION_90。装置逆时针旋转90度。

+0

但我在兼容性关键词上得到编译错误...这是一个android类吗? – user1624552

+0

不,这是增强现实课程的一部分。在android中你必须使用view.getDisplay.getRotation();代替。 https://github.com/Bhide/AugmentedRealityView/blob/master/ARView/src/com/raw/utils/Compatibility.java – shanyour

+0

好吧,我想这段代码int rotation = Compatibility.getRotation(this),和以下条件不适用于我,因为我只想过滤加速度计和磁场值。通过应用lowPass功能就足够了吧? – user1624552