Math.tan

Posted on
  • Hi Gordon

    This code works in node, but on a espruino we get NaN

    R2D=57.29577951308;
    D2R=0.01745329251;
    L=1430093322686.17651367187;
    RA = R2D * Math.atan(0.91764 * Math.tan(L * D2R));
    console.log('Gordon:'+RA);
    

    Node:

    root@purple:~# cat test.js 
    R2D=57.29577951308;
    D2R=0.01745329251;
    L=1430093322686.17651367187;
    RA = R2D * Math.atan(0.91764 * Math.tan(L * D2R));
    console.log('Gordon:'+RA);
    
    root@purple:~# node test.js 
    Gordon: 49.01889864197386
    root@purple:~# 
    
    

    Espruino 1V84:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v84 Copyright 2015 G.Williams
    >echo(0);
    Gordon:NaN
    =undefined
    > 
    

    Merry Christmas

    Sacha

  • >RA = R2D * Math.atan(0.91764 * Math.tan((L * D2R)%3.14159265359));
    =48.92394847104
    
  • Thanks - so we're saying that Math.tan only works between -PI and PI? Should be easy enough to fix

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Math.tan

Posted by Avatar for Sacha @Sacha

Actions