1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Cartesian3.fromRadians = function ( longitude, latitude, height, ellipsoid, # default is WGS84 result ) { Check.typeOf.number("longitude", longitude); Check.typeOf.number("latitude", latitude);
height = defaultValue(height, 0.0); var radiiSquared = defined(ellipsoid) ? ellipsoid.radiiSquared : wgs84RadiiSquared;
var cosLatitude = Math.cos(latitude); scratchN.x = cosLatitude * Math.cos(longitude); scratchN.y = cosLatitude * Math.sin(longitude); scratchN.z = Math.sin(latitude); scratchN = Cartesian3.normalize(scratchN, scratchN);
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK); var gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK)); scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK); scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
if (!defined(result)) { result = new Cartesian3(); } return Cartesian3.add(scratchK, scratchN, result); };
|