I might be mistaking but it looks like these formulas would suggest a
perfectly round earth, or at least an equally "ratio'd" earth. I'm
pretty sure it's not. 

Ralph.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Brian LeRoux
Sent: donderdag 14 december 2006 2:36
To: Open Source Flash Mailing List
Subject: [osflash] distance between two points of lat/long

Getting some slightly 'off' results...anyone w/ a little geodata
experience up for checking my math here? Really appreciate any
suggestions for improving the code here too!

Cheers,
Brian



function distance( lat1:Number, lon1:Number, lat2:Number, lon2:Number,
unit:String ):Number
        {
                var theta = lon1 - lon2;
                var dist = Math.sin(deg2rad(lat1)) *
Math.sin(deg2rad(lat2)) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.cos(deg2rad(theta))
        
                dist = Math.acos(dist)
                dist = rad2deg(dist)
        
                var theDistance = dist * 60 * 1.1515
        
                switch( unit )
                {
                        case "K":
                                theDistance = distance * 1.609344
                        break;
                        
                        case "N":
                                theDistance = distance * 0.8684
                        break;
                }
                
                return theDistance
        }
        
        function deg2rad( n:Number ):Number
        {
                return( n * Math.PI / 180 )
        }

        function rad2deg( n:Number ):Number
        {
                return( n * 180 / Math.PI )
        }

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to