2015-10-12 157 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