Calculating distance between zip codes in PHP

This is mike’s answer with some annotations for the magic numbers. It seemed to work fine for me for some test data: function calc_distance($point1, $point2) { $radius = 3958; // Earth’s radius (miles) $deg_per_rad = 57.29578; // Number of degrees/radian (for conversion) $distance = ($radius * pi() * sqrt( ($point1[‘lat’] – $point2[‘lat’]) * ($point1[‘lat’] – … Read more

Distance moved by Accelerometer

You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video. However the gyro mouse might work for your application, see between 37:00-38:25 in the video. Similar questions: track small movements of … Read more

What is the fastest algorithm to calculate the minimum distance between two sets of points?

Perhaps you should check out (PDF warning! Also note that, for some reason, the order of the pages is reversed) “Optimal Algorithms for Computing the Minimum Distance Between Two Finite Planar Sets” by Toussaint and Bhattacharya: It is shown in this paper that the minimum distance between two finite planar sets if [sic] n points … Read more