Math 昼时计算

Math 昼时计算,math,trigonometry,julian-date,Math,Trigonometry,Julian Date,我很难得到这个表达式的数值,我试图用这个公式计算白天的时间。当我评估时,结果是给出了一个NaN 这个表达 代表朱利安日。(例如今天的J=172;) 任何帮助都是非常有价值的, 谢谢 我试过了,得到了答案…: P = Math.Asin(0.39795 * Math.Cos(0.2163108 + 2 * Math.Atan(0.9671396 * Math.Tan(0.00860 * (J- 186))))); 我把“[”改为”(“在Math.tan[0.00860*(J-186)]) 我得到

我很难得到这个表达式的数值,我试图用这个公式计算白天的时间。当我评估时,结果是给出了一个NaN 这个表达

代表朱利安日。(例如今天的J=172;)

任何帮助都是非常有价值的, 谢谢


我试过了,得到了答案…:

P = Math.Asin(0.39795 * Math.Cos(0.2163108 + 2 * Math.Atan(0.9671396 * Math.Tan(0.00860 * (J- 186)))));
我把“[”改为”(“在Math.tan[0.00860*(J-186)])

我得到了一个结果…(为了测试它,我把J改为172)


确保p是双倍的,我试过了,得到了答案…:

P = Math.Asin(0.39795 * Math.Cos(0.2163108 + 2 * Math.Atan(0.9671396 * Math.Tan(0.00860 * (J- 186)))));
    //GET LATITUDE
            latitude = document.getElementById("latit").value;
            L = latitude;

            //GET JULIAN DAY
              Now=new Date();
              Now_Y=Now.getYear();
              if (Now_Y < 70)   { Now_Y=Now_Y*1+2000; }
              if (Now_Y < 1900) { Now_Y=Now_Y*1+1900; }
              Now_M=Now.getMonth();                     // Jan-Dec = 0-11
              Now_D=Now.getDate();                      // 1-31
              Now_H=Now.getHours();                     // 0-23
              Now_N=Now.getMinutes();                   // 0-59
              Now_S=Now.getSeconds();                   // 0-59
              Now_U=Now.getMilliseconds();              // 0-999
              Now_T=Now.getTime();                      // miliseconds since 1970-01-01
              Now_O=Now.getTimezoneOffset();            // in minutes
              Now_W=Now.getDay();                       // weekday: Sun-Sat = 0-6
              Now_J=                                    // day of year (Julian day)
                Math.round((                            // ...account for DST
                (new Date(Now_Y,Now_M,Now_D))           // ...most recent midnight
                - (new Date(Now_Y,0,0)))                // ...Dec. 31st midnight
                /86400000);                             // ...mili-seconds per day
              Gmt_N=Now_N+Now_O;
              Gmt=new Date(Now_Y,Now_M,Now_D,Now_H,Gmt_N,Now_S);
              Gmt_Y=Gmt.getYear();
              if (Gmt_Y < 70)   { Gmt_Y=Gmt_Y*1+2000; }
              if (Gmt_Y < 1900) { Gmt_Y=Gmt_Y*1+1900; }
              Gmt_M=Gmt.getMonth();                     // Jan-Dec = 0-11
              Gmt_D=Gmt.getDate();                      // 1-31
              Gmt_J=                                    // day of year (Julian day)
                Math.round((                            // ...account for DST
                (new Date(Gmt_Y,Gmt_M,Gmt_D))           // ...most recent midnight
                - (new Date(Gmt_Y,0,0)))                // ...Dec. 31st midnight
                /86400000);                             // ...mili-seconds per day
                alert("Julian Day: "+Gmt_J);

            J = Gmt_J;

            P = Math.asin(0.39795*Math.cos(0.2163108 + 2*Math.atan(0.9671396*Math.tan(0.00860*(J-186)))));

            alert("P is : "+P)

            pi = 3.14159265;

            var D = 24 - (24/pi)*Math.acos((Math.sin(0.8333*pi/180) + Math.sin(L*pi/180)*Math.sin(P))/ (Math.cos(L*pi/18

0)*Math.cos(P)));
我把“[”改为”(“在Math.tan[0.00860*(J-186)])

我得到了一个结果…(为了测试它,我把J改为172)

确保p是双倍的

//获取纬度
    //GET LATITUDE
            latitude = document.getElementById("latit").value;
            L = latitude;

            //GET JULIAN DAY
              Now=new Date();
              Now_Y=Now.getYear();
              if (Now_Y < 70)   { Now_Y=Now_Y*1+2000; }
              if (Now_Y < 1900) { Now_Y=Now_Y*1+1900; }
              Now_M=Now.getMonth();                     // Jan-Dec = 0-11
              Now_D=Now.getDate();                      // 1-31
              Now_H=Now.getHours();                     // 0-23
              Now_N=Now.getMinutes();                   // 0-59
              Now_S=Now.getSeconds();                   // 0-59
              Now_U=Now.getMilliseconds();              // 0-999
              Now_T=Now.getTime();                      // miliseconds since 1970-01-01
              Now_O=Now.getTimezoneOffset();            // in minutes
              Now_W=Now.getDay();                       // weekday: Sun-Sat = 0-6
              Now_J=                                    // day of year (Julian day)
                Math.round((                            // ...account for DST
                (new Date(Now_Y,Now_M,Now_D))           // ...most recent midnight
                - (new Date(Now_Y,0,0)))                // ...Dec. 31st midnight
                /86400000);                             // ...mili-seconds per day
              Gmt_N=Now_N+Now_O;
              Gmt=new Date(Now_Y,Now_M,Now_D,Now_H,Gmt_N,Now_S);
              Gmt_Y=Gmt.getYear();
              if (Gmt_Y < 70)   { Gmt_Y=Gmt_Y*1+2000; }
              if (Gmt_Y < 1900) { Gmt_Y=Gmt_Y*1+1900; }
              Gmt_M=Gmt.getMonth();                     // Jan-Dec = 0-11
              Gmt_D=Gmt.getDate();                      // 1-31
              Gmt_J=                                    // day of year (Julian day)
                Math.round((                            // ...account for DST
                (new Date(Gmt_Y,Gmt_M,Gmt_D))           // ...most recent midnight
                - (new Date(Gmt_Y,0,0)))                // ...Dec. 31st midnight
                /86400000);                             // ...mili-seconds per day
                alert("Julian Day: "+Gmt_J);

            J = Gmt_J;

            P = Math.asin(0.39795*Math.cos(0.2163108 + 2*Math.atan(0.9671396*Math.tan(0.00860*(J-186)))));

            alert("P is : "+P)

            pi = 3.14159265;

            var D = 24 - (24/pi)*Math.acos((Math.sin(0.8333*pi/180) + Math.sin(L*pi/180)*Math.sin(P))/ (Math.cos(L*pi/18

0)*Math.cos(P)));
纬度=document.getElementById(“latit”).value; L=纬度; //获得朱利安日 现在=新日期(); Now_Y=Now.getYear(); 如果(Now_Y<70){Now_Y=Now_Y*1+2000;} 如果(Now_Y<1900){Now_Y=Now_Y*1+1900;} Now_M=Now.getMonth();//Jan-Dec=0-11 Now_D=Now.getDate();//1-31 Now_H=Now.getHours();//0-23 Now_N=Now.getMinutes();//0-59 Now_S=Now.getSeconds();//0-59 Now_=Now.getmillizes();//0-999 Now_T=Now.getTime();//自1970-01-01以来的毫秒数 Now_O=Now.getTimezoneOffset();//分钟 Now_W=Now.getDay();//工作日:太阳周六=0-6 Now_J=//一年中的某一天(朱利安日) 数学四舍五入((//…占DST) (新日期(现在是,现在是,现在是),最近的午夜 -(新日期(现在是0,0))/…12月31日午夜 /每天86400000);/…毫秒 格林尼治标准时间=现在+现在; Gmt=新日期(现在是,现在是,现在是D,现在是H,Gmt是,现在是S); Gmt_Y=Gmt.getYear(); 如果(Gmt_Y<70){Gmt_Y=Gmt_Y*1+2000;} 如果(Gmt_Y<1900){Gmt_Y=Gmt_Y*1+1900;} Gmt_M=Gmt.getMonth();//一月至十二月=0-11 Gmt_D=Gmt.getDate();//1-31 Gmt_J=//一年中的哪一天(朱利安日) 数学四舍五入((//…占DST) (新日期(Gmt_Y,Gmt_M,Gmt_D))/…最近的午夜 -(新日期(格林威治标准时间0,0))/…12月31日午夜 /每天86400000);/…毫秒 警报(“朱利安日:+Gmt_J”); J=格林尼治标准时间; P=Math.asin(0.39795*Math.cos(0.2163108+2*Math.atan)(0.9671396*Math.tan(0.00860*(J-186 '))); 警报(“P为:”+P) pi=3.14159265; 变量D=24-(24/pi)*数学acos((数学sin(0.8333*pi/180)+数学sin(L*pi/180)*数学sin(P))/(数学cos(L*pi/18 0)*数学cos(P));
//获取纬度
纬度=document.getElementById(“latit”).value;
L=纬度;
//获得朱利安日
现在=新日期();
Now_Y=Now.getYear();
如果(Now_Y<70){Now_Y=Now_Y*1+2000;}
如果(Now_Y<1900){Now_Y=Now_Y*1+1900;}
Now_M=Now.getMonth();//Jan-Dec=0-11
Now_D=Now.getDate();//1-31
Now_H=Now.getHours();//0-23
Now_N=Now.getMinutes();//0-59
Now_S=Now.getSeconds();//0-59
Now_=Now.getmillizes();//0-999
Now_T=Now.getTime();//自1970-01-01以来的毫秒数
Now_O=Now.getTimezoneOffset();//分钟
Now_W=Now.getDay();//工作日:太阳周六=0-6
Now_J=//一年中的某一天(朱利安日)
数学四舍五入((//…占DST)
(新日期(现在是,现在是,现在是),最近的午夜
-(新日期(现在是0,0))/…12月31日午夜
/每天86400000);/…毫秒
格林尼治标准时间=现在+现在;
Gmt=新日期(现在是,现在是,现在是D,现在是H,Gmt是,现在是S);
Gmt_Y=Gmt.getYear();
如果(Gmt_Y<70){Gmt_Y=Gmt_Y*1+2000;}
如果(Gmt_Y<1900){Gmt_Y=Gmt_Y*1+1900;}
Gmt_M=Gmt.getMonth();//一月至十二月=0-11
Gmt_D=Gmt.getDate();//1-31
Gmt_J=//一年中的哪一天(朱利安日)
数学四舍五入((//…占DST)
(新日期(Gmt_Y,Gmt_M,Gmt_D))/…最近的午夜
-(新日期(格林威治标准时间0,0))/…12月31日午夜
/每天86400000);/…毫秒
警报(“朱利安日:+Gmt_J”);
J=格林尼治标准时间;
P=Math.asin(0.39795*Math.cos(0.2163108+2*Math.atan)(0.9671396*Math.tan(0.00860*(J-186 ')));
警报(“P为:”+P)
pi=3.14159265;
变量D=24-(24/pi)*数学acos((数学sin(0.8333*pi/180)+数学sin(L*pi/180)*数学sin(P))/(数学cos(L*pi/18
0)*数学cos(P));

在这些情况下,当我遇到问题时,我总是将代码分为多个lin