Distance calculation implementation What I'm asking for is the review of a particular implementation of the haversine formula, found under:
http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html
This site is linked under the wikipedia article: http://en.wikipedia.org/wiki/Haversine_formula

Problem: I get the wrong distance for the points:

lat/lon, lat2/lon2

36.987814/-122.107887,   38.989185/-122.116728


I get a distance of 4336622.8812906 (meters)
however according to http://www.movable-type.co.uk/scripts/latlong.html it should be about 222.5 km.

If somebody could point out the error in this implementation, that would be great:

inline double getDist(double *gp) {
    /// @brief The usual PI/180 constant
    static const double DEG_TO_RAD = 0.017453292519943295769236907684886;
    /// @brief Earth's quatratic mean radius for WGS-84
    static const double EARTH_RADIUS_IN_METERS = 6372797.560856;

    double latitudeArc  = (gp[0] - gp[2]) * DEG_TO_RAD;
    double longitudeArc = (gp[1] - gp[3]) * DEG_TO_RAD;
    double latitudeH = sin(latitudeArc * 0.5);
    latitudeH *= latitudeH;
    double lontitudeH = sin(longitudeArc * 0.5);
    lontitudeH *= lontitudeH;
    double tmp = cos(gp[0]*DEG_TO_RAD) * cos(gp[2]*DEG_TO_RAD);
    return EARTH_RADIUS_IN_METERS*2.0 * asin(sqrt(latitudeH + tmp*lontitudeH));
}
There's nothing wrong with your implementation. There must therefore be something wrong with how you're declaring or populating gp.
Doing it like this:

double gp[4] = {36.987814, -122.107887, 38.989185, -122.116728};
printf("%.6f\n", getDist(gp));


gives the expected answer of 222606.439993