Created
December 5, 2019 01:52
-
-
Save cosinekitty/6b37476d4e94271a0214d8aa604d8017 to your computer and use it in GitHub Desktop.
Function for calculating Earth radius at a specific geodetic latitude.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function EarthRadiusInMeters(latitudeRadians) | |
{ | |
// latitudeRadians is geodetic, i.e. that reported by GPS. | |
// http://en.wikipedia.org/wiki/Earth_radius | |
var a = 6378137.0; // equatorial radius in meters | |
var b = 6356752.3; // polar radius in meters | |
var cos = Math.cos(latitudeRadians); | |
var sin = Math.sin(latitudeRadians); | |
var t1 = a * a * cos; | |
var t2 = b * b * sin; | |
var t3 = a * cos; | |
var t4 = b * sin; | |
return Math.sqrt((t1*t1 + t2*t2) / (t3*t3 + t4*t4)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment