iphone moving direction using accelerometer
Posted
by Ruchir Shah
on Stack Overflow
See other posts from Stack Overflow
or by Ruchir Shah
Published on 2010-05-20T16:27:20Z
Indexed on
2010/05/20
16:30 UTC
Read the original article
Hit count: 278
Hi,
I want some help on UIAccelerometer class. I want to find some way to find out or distinguish when I wave iphone device from right-to-left and the left-to-right. I am getting x,y,z values as well as interval value. I am also getting velocity and distance calculated from normal physics rule.
Distance = (prevDist + sqrt(pow((prevx - acceleration.x), 2) + pow((prevy - acceleration.y), 2) + pow((prevz - acceleration.z), 2)))
Velocity = (Distance * timeintercal) { here distance means newdistance-prevdistance and timeinterval for that distance }
When I am moving iphone device right-to-left then left-to-right I am getting total distance traveld in both direction and velocity at regular intervals. Can you help me how I can find out that I am moving iphone device left-to-right or right-to-left?
Help would be appreciated. Thanks.
© Stack Overflow or respective owner