views:

162

answers:

4

I'm designing a pedometer application for the iPhone. Given the number of steps a user has taken, how do I determine the distance in miles they have traveled?

A: 

To calculate the speed, you also need to know the total time the user has spent walking.

If the user has walked M miles for total of T minutes, the average speed is (M * 60) / T mph. If the user has made a total of S steps for that same time, he's been doing an average of S / (T * 60) steps per second.

Franci Penov
A: 

If you know the number of miles, divide it by hours. Voila, miles per hour. Per second, further divide by 3600 and you'll have miles per second. If Google is right, 1 mile = 5280 feet, so by multiplying the last result by feet, you'll have feet per second.

// assuming miles and hours is known
mph = miles / hours;
fps = mph / 3600 * 5280;
Piskvor
of course, we all know that on the new revolutionary iPhone 4 Retina display, there are four times as many feet per mile (`21120` vs. Android's measly `5280`)
Franci Penov
A: 

If you are using CLLocation Class then

Try to implement CLLocationSpeed which will give you the speed at which device is moving in meters/second.

Ex.

CLLocation *locationObject;

double calculateSpeedMPS=locationObject.speed;

// 1 meter per second = 2.23693629 miles per hour

double calculateSpeedMPH=calculateSpeedMPS*2.23693629;
raaz
Well, that's not gonna work unless he averages the measurements over a period of time. As per documentation - "Because the actual speed can change many times between the delivery of subsequent location events, you should use this property for informational purposes only."
Franci Penov
A: 

The user should have a friend take a picture of them (with their phone) striding over a 12" ruler. Preferably, the photographer has the camera parallel to the ruler. Let them click on both toes and both ends of the ruler and do the math to calculate stride length (est). If you know the number of steps...

Jeff O