title: Polar to Cartesian coordinates function not outputting the correct data
body: <p>I have a flight path with lat/long and elevation and I need to convert this to cartesin X,Y,Z for cesium.js.
  I am running into the wall trying to convert this because I don't seem to be getting the right results from my function. </p>
  
  <pre><code>var R = 6371;
  function polarToCartesian(latitude, longitude, elevation){
      x = (R+elevation) * math.cos(latitude) * math.cos(longitude);
      y = (R+elevation) * math.cos(latitude) * math.sin(longitude);
      z = (R+elevation) * math.sin(latitude);
  
      var ar = [x,y,z];
      return  ar;
  }
  </code></pre>
  
  <p>I must not either have the correct formula for polar to cartesian or I don't have the correct radius of earth. I found somewhere that my radius should be 6371 but can't seem to find that same SO question for reference. </p>
  
  <p>I am partialy checking if my code is correct by manually adding up the radius of the earth + altitude of the flight path at a given location and seeing if this equals the length of my x,y,z vector. </p>
  
  <p>For example: x,y,z <code>(3689.2472215653725,3183.2401988117012,13306.90338789763)</code>
  is outputted when I give my function this </p>
  
  <pre><code>-93.028,44.6942,7800
  </code></pre>
  
  <p>lat,long,elevation </p>
  
  <p>Could someone point me to find the right js code to accomplish this conversion? </p>