How can I calculate distance and vertical velocity?

Can't I just add up all of the accelerations of the accelerometer and then use this physics equation to get distance?

d = v(i) x t + (1/2) x a x t ^2

In this: v(i) would be 0 t = 1 second a = all accelerometer speeds added together for.1 second t = 1 second

Can't I just use this equation to get vertical velocity? A lot of people have said it is impossible but It has been done with variometer apps. I can’t figure out the code. Can anyone guide me in the right direction?

v(f) = v(i) + a x t

v(i) = 0 a = y-axis acceleration for 1 second t = 1 second

Please let me know if this is possible.

Thank you so much for your help.

Sure, you can integrate acceleration to get velocity and integrate velocity to get distance. But the problem is that you integrate all the errors in the sensor values too, and they quickly dominate.

This is a well-known problem that has been studied in the context of submarine, aircraft and spacecraft navigation (pre-GPS) for decades. The solutions tend to be either ever-more precise sensors (which is not something you can change on a phone) and "sensor fusion", where you blend your integrated value with a value from another sensor. One example of sensor fusion is the Kalman Filter - look it up.

Do be aware that the sensor values that you get on iOS have probably already been processed in some way by the system before you receive them.

How can I calculate distance and vertical velocity?
 
 
Q