2
類似android中的GPS狀態應用我想獲得「磁場的絕對強度」和「理論力量」。我能夠使用GeomagneticField
getFieldStrength()
方法獲得理論實力。磁場的絕對強度:Android
但我不確定如何從傳感器獲得「絕對磁場強度」。
請幫忙。
謝謝。
類似android中的GPS狀態應用我想獲得「磁場的絕對強度」和「理論力量」。我能夠使用GeomagneticField
getFieldStrength()
方法獲得理論實力。磁場的絕對強度:Android
但我不確定如何從傳感器獲得「絕對磁場強度」。
請幫忙。
謝謝。
如果你正在尋找的磁場強度的絕對值,你可以簡單地按照以下方法計算的:
private final SensorEventListener mySensorListener = new SensorEventListner() {
public void onSensorChange(SensorEvent event) {
sensorRead = event.value;
int sensorType = event.sensor.getType();
if(sensorType = Sensor.TYPE_MAGNETIC_FIELD) {
mag = sensorRead;
magAbsVal = Math.sqrt(mag[0]*mag[0] + mag[1]*mag[1] + mag[2]*mag[2]);
}
}
}
這會給你從磁力讀取絕對的UT值。如果您正在查找百分比值,則可以使用percentMag = largestMag/magAbsVal
。
希望它有幫助。
largetstMag的價值是什麼? – gregm 2014-07-08 12:15:42
嗨,我可以通過磁場的「絕對強度」知道您的意思嗎? – TheCodeArtist 2011-03-05 14:54:34