Chris Nolan [http://chrisnolan.ca/] has help to light a fire under my
ass about this outstanding math equation.  Are there an math/geo gurus
out there who can help me to get this working?

Here is a sample PHP page that attempts to display the distance
between Seattle and New York (given only their lat/lon values). 
According to this, I'm getting 3869 miles between the two cities, but
my road atlas says only 2816 miles.

// GET VARIABLES
$unit = $_REQUEST['unit'];

// EARTH RADIUS
$radius_mi = 3443.9;
$radius_km = 6378;

// VALUE OF PI
$pi = 3.14159265;

// UNITS OF MEASUREMENT
if ($unit = "km") {
 $r = $radius_km;
} else {
 $r = $radius_mi;
}

// SEATTLE LAT&LON
$a1 = 47.6125;
$b1 = -122.328;

// NEW YORK LAT&LON
$a2 = 40.714;
$b2 = -74.007;

// COMMENTS STOP HERE
// BECAUSE I'M LOST

$a1 = abs($a1) * ($pi/180);
$b1 = abs($b1) * ($pi/180);

$a2 = abs($a2) * ($pi/180);
$b2 = abs($b2) * ($pi/180);

$distance = acos(cos($a1)*cos($b1)*cos($a2)*cos($b2) +
cos($a1)*sin($b1)*cos($a2)*sin($b2) + sin($a1)*sin($a2)) * $r;

echo $distance . "<br />\n";




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/lBLqlB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/videoblogging/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Reply via email to