我想检测使用磁性传感器值的金属。我正在连续地获取值如x = 30.00,Y = -20.00,Z = -13.00如何在Android手机中使用磁性传感器检测金属?
现在我想知道如何使用这些值,用于检测任何金属(mathameticalcalu,公式)
代码是
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
// get compass sensor (ie magnetic field)
myCompassSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
float azimuth = Math.round(event.values[0]);
float pitch = Math.round(event.values[1]);
float roll = Math.round(event.values[2]);
是否这样? '//计算字段值现在 浮子magHere =(浮点)Math.sqrt(Math.pow(X,2)+ Math.pow(Y,2)+ Math.pow(Z,2)); //计算预期值 float magExpected =(float)Math.sqrt(geoField.getX()+ geoField.getY()+ geoField.getZ());' – 2014-04-10 16:42:45
链接到上面的代码,[Pastebin](http: //pastebin.com/pStMSpNd) – 2014-04-10 16:49:31
你忘记方geoField – chopchop 2014-04-11 10:48:07