Hello missmoun,

When I read that you are doing this for a wearable device, and that you are processing GPS data to find the distance between two points on the Earth, does that mean that the two points are likely to be very close together? For example, if you are trying to figure out the distance around the Earth from Japan to England, you definitely need some complicated formulas. On the other hand, if you just want the distance between two points that are very close together (like a few miles on a sphere the size of the Earth), you can greatly simplify things.

For points very close together, the straight-line distance will be a very good approximation for the curvilinear distance across the ground. We simplify by assuming that we can break down the distance into an east-west distance (delta_x) and north-south distance (delta_y).

delta_x = cos((latitude1 + latitude2) / 2) * (longitude1 - longitude2) * earth_radius;

delta_y = (latitude1 - latitude2) * earth_radius; // note that latitudes MUST be in radians!

approx_distance = sqrt (delta_x*delta_x + delta_y*delta_y);

This formula requires only one trig function: cosine. If you are using this in a particular geographical area, you could do a really easy hack: just hard-code the value cos(your_latitude) into your program! The formula for delta_x becomes:

delta_x = your_cosine_latitude * (longitude1 - longitude2) * earth_radius;

Then the only tricky math you have to do is sqrt, which is very easy to implement using divide-and-average.