seamaster:
What is the formula to use for average the movements?
For each axis, add up all the samples over a period and divide by the number of samples. This gives you an average for each axis. Then use simple trig to calculate the direction of the resulting vector - that's your vertical.