imlfn.js 503 B

12345678910111213141516
  1. export default function(ml, e0, e1, e2, e3) {
  2. var phi;
  3. var dphi;
  4. phi = ml / e0;
  5. for (var i = 0; i < 15; i++) {
  6. dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));
  7. phi += dphi;
  8. if (Math.abs(dphi) <= 0.0000000001) {
  9. return phi;
  10. }
  11. }
  12. //..reportError("IMLFN-CONV:Latitude failed to converge after 15 iterations");
  13. return NaN;
  14. }