Android studio I am trying to find distance in android studi
Android studio
I am trying to find distance in android studio.
For example, in my walking app I want to set an alarm when the desired distance has been reached. So how do I find the desired steps or distance using android studio sensors such as accelerometer. Youtube shows how to implement accelerometer but not how to find the distance using it. Please show me how to do that.
Solution
The formula which can be used to find the distance is :-
VELOCITY =(GRAVITY*ACCELERATION)/(2*PI*FREQUENCY)
DISTANCE=TIME TAKEN*SPEED.
Where Value of PI is 3.14.
For ex:-
inputArray[i]=sqrt(X*X+Y*Y+Z*Z);
for(i=0;i<1000;i++)
{
if(inputArray[i]<0
{
inputArray[i]=inputArray[i]-(inputArray[i]*2);
}
}
static double PI=3.141592;
static double gravity=9806.65;
double Acce(double accel,double freq)
{
double result =0;
result =(gravity*accel)/(2*PI*freq);
return result;
}
