{"id":856,"date":"2017-02-02T19:30:07","date_gmt":"2017-02-02T11:30:07","guid":{"rendered":"http:\/\/www.luwl.net\/?p=856"},"modified":"2017-02-02T19:30:07","modified_gmt":"2017-02-02T11:30:07","slug":"%e6%97%a5%e5%87%ba%e6%97%a5%e8%90%bd%e8%ae%a1%e7%ae%97","status":"publish","type":"post","link":"http:\/\/www.luwl.net\/?p=856","title":{"rendered":"\u65e5\u51fa\u65e5\u843d\u8ba1\u7b97"},"content":{"rendered":"<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\n#include &quot;config.h&quot;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;math.h&gt;\r\n\r\nfloat code degreesToRadians = 3.1416 \/180.0000;\r\nfloat code radiansToDegrees = 180.0000 \/3.1416;\r\nfloat code degreeMinutesToDecimal = 1.0000 \/60.0000;\r\nfloat code degreeSecondsToDecimal = 1.0000 \/3600.0000;\r\n\r\nbit input_East,input_South;\r\nfloat input_Longitude,input_Latitude,input_Elevation,input_Month,input_Date,input_Year,input_TimeZone;\/\/\u539f\u59cb\u9700\u8981\u6570\u636e\r\nint chu,luo;\/\/\u7ed3\u679c\r\nu8 chu1,chu2,luo1,luo2;\/\/\u7ed3\u679c\u8f6c\u4e3a\u5c0f\u65f6\u3001\u5206\u949f\r\n\r\nfloat NormalizeTo360 (theThing) {\r\nreturn (theThing - floor (theThing \/ 360.0) * 360);\r\n}\r\nvoid compute (void) {\r\nfloat signedLongitude,signedLatitude,meridian,longitudeMeridianDifference,correctedYear,correctedMonth; \/\/\u8ba1\u7b97\u7528\u8f6c\u6362\u6570\u636e\r\nfloat t,G,C,L,alpha,obliquity,declination,eotAdjustment,clockTimeToLSOTAdjustment,sunRiseSetLSoTMinutes; \/\/\u8ba1\u7b97\u7528\u4e2d\u95f4\u6570\u636e\r\nif (input_Latitude == 0) { input_Latitude = 0.000000001; }\r\nif (input_Longitude == 0) { input_Longitude = 0.000000001; }\r\nsignedLongitude = input_Longitude;\r\nif (input_East == 1) signedLongitude *= -1; \/\/ &#x5B;1] = \u4e1c, &#x5B;0] = \u897f\r\nsignedLatitude = input_Latitude;\r\nif (input_South == 1) signedLatitude *= -1; \/\/ &#x5B;0] = \u5317, &#x5B;1] = \u5357\r\n\/\/ \u4fee\u590d\u7ecf\u5ea6 &gt; 180 deg\r\nif (signedLongitude &gt; 180) {\r\nsignedLongitude = signedLongitude - 360;\r\n}\r\n\/\/ \u4fee\u590d\u7ecf\u5ea6&lt; -180 deg\r\nif (signedLongitude &lt; -180) {\r\nsignedLongitude = signedLongitude + 360;\r\n}\r\n\/\/ \u5f53\u5730\u6807\u51c6\u65f6\u95f4\u5b50\u5348\u7ebf\r\nmeridian = input_TimeZone * -15;\r\n\/\/ \u5982\u679c\u592a\u591a\u4e0e\u65f6\u533a\u7ecf\u5ea6\u4e0d\u540c\u7684\u8b66\u62a5\r\nlongitudeMeridianDifference = signedLongitude - meridian;\r\nif ((longitudeMeridianDifference &gt; 30) || (longitudeMeridianDifference &lt; -30)) {\r\n\/\/alert (&quot;\u6240\u9009\u62e9\u7684\u65f6\u533a\u4e0e\u6240\u5728\u4f4d\u7f6e\u5dee\u8ddd\u8f83\u5927\uff01&quot;);\r\n}\r\n\/\/ \u8ba1\u7b97\u901a\u7528\u65f6\u95f4\r\nif (input_Month &gt; 2) {\r\ncorrectedYear = input_Year;\r\ncorrectedMonth = input_Month - 3;\r\n}\r\nelse {\r\ncorrectedYear = input_Year - 1;\r\ncorrectedMonth = input_Month + 9;\r\n}\r\nt = (input_Date + floor (30.6 * correctedMonth + 0.5) + floor (365.25 * (correctedYear - 1976)) - 8707.5) \/ 36525.0;\r\nG = 357.528 + 35999.05 * t;\r\nG = NormalizeTo360 (G);\r\nC = (1.915 * sin (G * degreesToRadians)) + (0.020 * sin (2.0 * G * degreesToRadians));\r\nL = 280.460 + (36000.770 * t) + C;\r\nL = NormalizeTo360 (L);\r\nalpha = L - 2.466 * sin (2.0 * L * degreesToRadians) + 0.053 * sin (4.0 * L * degreesToRadians);\r\nobliquity = 23.4393 - 0.013 * t;\r\ndeclination = atan (tan (obliquity * degreesToRadians) * sin (alpha * degreesToRadians)) * radiansToDegrees;\r\neotAdjustment = (L - C - alpha) \/ 15.0;\r\nclockTimeToLSOTAdjustment = ((signedLongitude - meridian) \/ 15.0) - eotAdjustment; \/\/ \u4ee5\u5c0f\u65f6\u4e3a\u5355\u4f4d\r\nsunRiseSetLSoTMinutes = radiansToDegrees * acos ( -1.0 * (sin (signedLatitude * degreesToRadians) * sin (declination * degreesToRadians) - sin ((-0.8333 - 0.0347 * sqrt (input_Elevation)) * degreesToRadians)) \/ cos (signedLatitude * degreesToRadians) \/ cos (declination * degreesToRadians)) * 4;\r\n\/\/\u65e5\u51fa\u65f6\u95f4\r\nchu=12 * 60 - sunRiseSetLSoTMinutes + (clockTimeToLSOTAdjustment * 60);\r\n\/\/\u65e5\u843d\u65f6\u95f4\r\nluo=12 * 60 + sunRiseSetLSoTMinutes + (clockTimeToLSOTAdjustment * 60);\r\nchu1=(int)chu\/60;\r\nchu2=(int)chu%60;\r\nluo1=(int)luo \/ 60;\r\nluo2=(int)luo % 60;\r\n}\r\nvoid main (void) {\r\n\/\/\u63d0\u4f9b\u7684\u53c2\u6570\r\ninput_Longitude=114.41; \/\/\u7ecf\u5ea6\r\ninput_East=1;\/\/\u4e1c\u7ecf1\uff0c\u897f\u7ecf0\r\ninput_Latitude=36.93;\/\/\u7ef4\u5ea6\r\ninput_South=0;\/\/\u5317\u7eac0\uff0c\u5357\u7eac1\r\ninput_Year=2017;\r\ninput_Month=2;\r\ninput_Date=2;\r\ninput_TimeZone=8;\r\nwhile(1){\r\ncompute();\r\n}\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &quot;config.h&quot; #include &#038; &hellip; <a href=\"http:\/\/www.luwl.net\/?p=856\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-856","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=856"}],"version-history":[{"count":1,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":857,"href":"http:\/\/www.luwl.net\/index.php?rest_route=\/wp\/v2\/posts\/856\/revisions\/857"}],"wp:attachment":[{"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.luwl.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}