Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 加速计,计算1米_Android - Fatal编程技术网

Android 加速计,计算1米

Android 加速计,计算1米,android,Android,我从加速度计接收x轴数据 ... float x = event.values[0]; ... 我如何计算1米并弹出祝酒词 Toast.makeText(getApplicationContext(), "1 meter", Toast.LENGTH_LONG).show(); 你不能,不仅仅是因为加速。记住你的基本物理知识: x=.5*a*t^2+v_0*t+x_0 即使你假设x_0=0(你只想改变位置),你也需要知道你的初始速度,通过加速计确定最终位置 你的另一个问题是噪音。加速度计的噪

我从加速度计接收x轴数据

...
float x = event.values[0];
...
我如何计算1米并弹出祝酒词

Toast.makeText(getApplicationContext(), "1 meter", Toast.LENGTH_LONG).show();

你不能,不仅仅是因为加速。记住你的基本物理知识:

x=.5*a*t^2+v_0*t+x_0

即使你假设x_0=0(你只想改变位置),你也需要知道你的初始速度,通过加速计确定最终位置

你的另一个问题是噪音。加速度计的噪音太大,无法以这种方式使用

如果要计算距离,请使用GPS。它在如此短的距离内仍然不起作用,但它比加速度计更能让你靠近