This post is a Micromite eXtreme program that calculates the calendar date and UTC (Universal Coordinated Time) time of the seasons. The only user input required is the calendar year of interest.
Here’s a typical user interaction with the software and the computed results.
time of the seasons
===================
please input the calendar year
? 2017
spring equinox
--------------
calendar date March 20 2017
UTC time 10 hours 28 minutes 31.97 seconds
summer solstice
---------------
calendar date June 21 2017
UTC time 4 hours 23 minutes 51.66 seconds
fall equinox
------------
calendar date September 22 2017
UTC time 20 hours 1 minutes 26.39 seconds
winter solstice
---------------
calendar date December 21 2017
UTC time 16 hours 27 minutes 54.68 seconds
Here’s a copy of the MATLAB PDF document for this program.
Here’s the MMBASIC source code for this program;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
' seasons.bas March 6, 2017 ' calendar date and UTC time of the seasons ' Micromite eXtreme version ''''''''''''''''''''''''''' ' dimension global arrays dim sl(50) as float, sr(50) as float, sa(50) as float, sb(50) as float dim jdleap(27) as float, leapsec(27) as float, month$(12) as string ' global constants const pi2 = 2.0 * pi, pidiv2 = 0.5 * pi, dtr = pi / 180.0 ' read solar ephemeris data for i% = 1 to 50 read sl(i%), sr(i%), sa(i%), sb(i%) next i% data 403406, 0, 4.721964, 1.621043 data 195207, -97597, 5.937458, 62830.348067 data 119433, -59715, 1.115589, 62830.821524 data 112392, -56188, 5.781616, 62829.634302 data 3891, -1556, 5.5474 , 125660.5691 data 2819, -1126, 1.5120 , 125660.9845 data 1721, -861, 4.1897 , 62832.4766 data 0, 941, 1.163 , 0.813 data 660, -264, 5.415 , 125659.310 data 350, -163, 4.315 , 57533.850 data 334, 0, 4.553 , -33.931 data 314, 309, 5.198 , 777137.715 data 268, -158, 5.989 , 78604.191 data 242, 0, 2.911 , 5.412 data 234, -54, 1.423 , 39302.098 data 158, 0, 0.061 , -34.861 data 132, -93, 2.317 , 115067.698 data 129, -20, 3.193 , 15774.337 data 114, 0, 2.828 , 5296.670 data 99, -47, 0.52 , 58849.27 data 93, 0, 4.65 , 5296.11 data 86, 0, 4.35 , -3980.70 data 78, -33, 2.75 , 52237.69 data 72, -32, 4.50 , 55076.47 data 68, 0, 3.23 , 261.08 data 64, -10, 1.22 , 15773.85 data 46, -16, 0.14 , 188491.03 data 38, 0, 3.44 , -7756.55 data 37, 0, 4.37 , 264.89 data 32, -24, 1.14 , 117906.27 data 29, -13, 2.84 , 55075.75 data 28, 0, 5.96 , -7961.39 data 27, -9, 5.09 , 188489.81 data 27, 0, 1.72 , 2132.19 data 25, -17, 2.56 , 109771.03 data 24, -11, 1.92 , 54868.56 data 21, 0, 0.09 , 25443.93 data 21, 31, 5.98 , -55731.43 data 20, -10, 4.03 , 60697.74 data 18, 0, 4.27 , 2132.79 data 17, -12, 0.79 , 109771.63 data 14, 0, 4.24 , -7752.82 data 13, -5, 2.01 , 188491.91 data 13, 0, 2.65 , 207.81 data 13, 0, 4.98 , 29424.63 data 12, 0, 0.93 , -7.99 data 10, 0, 2.21 , 46941.14 data 10, 0, 3.59 , -68.29 data 10, 0, 1.50 , 21463.25 data 10, -9, 2.55 , 157208.40 ' read leap second data for i% = 1 to 27 read jdleap(i%), leapsec(i%) next i% data 2441317.5, 10.0 data 2441499.5, 11.0 data 2441683.5, 12.0 data 2442048.5, 13.0 data 2442413.5, 14.0 data 2442778.5, 15.0 data 2443144.5, 16.0 data 2443509.5, 17.0 data 2443874.5, 18.0 data 2444239.5, 19.0 data 2444786.5, 20.0 data 2445151.5, 21.0 data 2445516.5, 22.0 data 2446247.5, 23.0 data 2447161.5, 24.0 data 2447892.5, 25.0 data 2448257.5, 26.0 data 2448804.5, 27.0 data 2449169.5, 28.0 data 2449534.5, 29.0 data 2450083.5, 30.0 data 2450630.5, 31.0 data 2451179.5, 32.0 data 2453736.5, 33.0 data 2454832.5, 34.0 DATA 2456109.5, 35.0 data 2457204.5, 36.0 ' calendar months month$(1) = "January" month$(2) = "February" month$(3) = "March" month$(4) = "April" month$(5) = "May" month$(6) = "June" month$(7) = "July" month$(8) = "August" month$(9) = "September" month$(10) = "October" month$(11) = "November" month$(12) = "December" '''''''''''''''''' ' begin simulation '''''''''''''''''' print " " print "time of the seasons" print "===================" print " " ' request calendar year print "please input the calendar year" input year ' process each season for iequsol% = 1 to 4 select case iequsol% case (1) cmonth = 3 day = 15 julian(cmonth, day, year, jdayi) case (2) cmonth = 6 day = 15 julian(cmonth, day, year, jdayi) along2 = 0.5 * pi case (3) cmonth = 9 day = 15 julian(cmonth, day, year, jdayi) case (4) cmonth = 12 day = 15 julian(cmonth, day, year, jdayi) along2 = 1.5 * pi end select ' find event x1 = 0.0 x2 = 10.0 realroot1(x1, x2, 1.0e-8, xroot, froot) ' TDB julian day of event jdtdb = jdayi + xroot ' compute UTC julian day tdb2utc(jdtdb, jdutc) ' print results for this event print " " select case iequsol% case (1) print "spring equinox" print "--------------" case (2) print "summer solstice" print "---------------" case (3) print "fall equinox" print "------------" case (4) print "winter solstice" print "---------------" end select print " " gdate (jdutc, cmonth, day, year) print "calendar date ", month$(cmonth), " ", STR$(int(day)), " ", str$(year) print " " thr0 = 24.0 * (day - int(day)) thr = int(thr0) tmin0 = 60.0 * (thr0 - thr) tmin = int(tmin0) tsec = 60.0 * (tmin0 - tmin) print "UTC time ", str$(thr) + " hours " + str$(tmin) + " minutes " + str$(tsec, 0, 2) + " seconds" next iequsol% print " " end ''''''''''''''' ''''''''''''''' sub esfunc(x, fx) ' equinox/solstice objective function ''''''''''''''''''''''''''''''''''''' local jday, rlsun, rasc, decl jday = jdayi + x solar(jday, rlsun, rasc, decl) if (iequsol% = 1 or iequsol% = 3) then fx = decl else fx = along2 - rlsun end if end sub '''''''''''''''''''''''' '''''''''''''''''''''''' sub tdb2utc (jdtdb, jdutc) ' convert TDB julian day to UTC julian day subroutine ' input ' jdtdb = TDB julian day ' output ' jdutc = UTC julian day ''''''''''''''''''''''''' local x1, x2, xroot, froot jdsaved = jdtdb ' set lower and upper bounds x1 = jdsaved - 0.1 x2 = jdsaved + 0.1 ' solve for UTC julian day using Brent's method realroot2(x1, x2, 1.0e-8, xroot, froot) jdutc = xroot end sub ''''''''''''''''''' ''''''''''''''''''' sub jdfunc (jdin, fx) ' objective function for tdb2utc ' input ' jdin = current value for UTC julian day ' output ' fx = delta julian day '''''''''''''''''''''''' local jdwrk, tai_utc findleap(jdin, tai_utc) utc2tdb(jdin, tai_utc, jdwrk) fx = jdwrk - jdsaved end sub ''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''' sub solar (jd, rlsun, rasc, decl) ' precision ephemeris of the Sun ' input ' jd = julian ephemeris day ' output ' rlsun = ecliptic longitude of the sun ' (0 <= rlsun <= 2 pi) ' rasc = right ascension of the Sun (radians) ' (0 <= rasc <= 2 pi) ' decl = declination of the Sun (radians) ' (-pi/2 <= decl <= pi/2) '''''''''''''''''''''''''''''''''' local u, a1, a2, psi, deps, meps, eps, seps, ceps local dl, dr, w, srl, crl, srb, crb, sra, cra u = (jd - 2451545.0) / 3652500.0 ' compute nutation in longitude a1 = 2.18 + u * (-3375.7 + u * 0.36) a2 = 3.51 + u * (125666.39 + u * 0.1) psi = 0.0000001 * (-834.0 * sin(a1) - 64.0 * sin(a2)) ' compute nutation in obliquity deps = 0.0000001 * u * (-226938 + u * (-75 + u * (96926 + u * (-2491 - u * 12104)))) meps = 0.0000001 * (4090928.0 + 446.0 * cos(a1) + 28.0 * cos(a2)) eps = meps + deps seps = sin(eps) ceps = cos(eps) dl = 0.0 dr = 0.0 for i% = 1 to 50 w = sa(i%) + sb(i%) * u dl = dl + sl(i%) * sin(w) if (sr(i%) <> 0.0) then dr = dr + sr(i%) * cos(w) end if next i% dl = modulo(dl * 0.0000001 + 4.9353929 + 62833.196168 * u) dr = 149597870.691 * (dr * 0.0000001 + 1.0001026) rlsun = modulo(dl + 0.0000001 * (-993.0 + 17.0 * cos(3.1 + 62830.14 * u)) + psi) rb = 0.0 ' compute geocentric declination and right ascension crl = cos(rlsun) srl = sin(rlsun) crb = cos(rb) srb = sin(rb) decl = asin(ceps * srb + seps * crb * srl) sra = -seps * srb + ceps * crb * srl cra = crb * crl rasc = atan3(sra, cra) end sub '''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''' sub realroot1(x1, x2, tol, xroot, froot) ' real root of a single non-linear function subroutine ' input ' x1 = lower bound of search interval ' x2 = upper bound of search interval ' tol = convergence criter%ia ' output ' xroot = real root of f(x) = 0 ' froot = function value ' note: requires sub esfunc ''''''''''''''''''''''''''' local eps, a, b, c, d, e, fa, fb, fcc, tol1 local xm, p, q, r, s, xmin, tmp eps = 2.23e-16 e = 0.0 a = x1 b = x2 esfunc(a, fa) esfunc(b, fb) fcc = fb for iter% = 1 to 50 if (fb * fcc > 0.0) then c = a fcc = fa d = b - a e = d end if if (abs(fcc) < abs(fb)) then a = b b = c c = a fa = fb fb = fcc fcc = fa end if tol1 = 2.0 * eps * abs(b) + 0.5 * tol xm = 0.5 * (c - b) if (abs(xm) <= tol1 or fb = 0.0) then exit for if (abs(e) >= tol1 and abs(fa) > abs(fb)) then s = fb / fa if (a = c) then p = 2.0 * xm * s q = 1.0 - s else q = fa / fcc r = fb / fcc p = s * (2.0 * xm * q * (q - r) - (b - a) * (r - 1.0)) q = (q - 1.0) * (r - 1.0) * (s - 1.0) end if if (p > 0.0) then q = -q p = abs(p) min = abs(e * q) tmp = 3.0 * xm * q - abs(tol1 * q) if (min < tmp) then min = tmp if (2.0 * p < min) then e = d d = p / q else d = xm e = d end if else d = xm e = d end if a = b fa = fb if (abs(d) > tol1) then b = b + d else b = b + sgn(xm) * tol1 end if esfunc(b, fb) next iter% froot = fb xroot = b end sub '''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''' sub realroot2(x1, x2, tol, xroot, froot) ' real root of a single non-linear function subroutine ' input ' x1 = lower bound of search interval ' x2 = upper bound of search interval ' tol = convergence criter%ia ' output ' xroot = real root of f(x) = 0 ' froot = function value ' note: requires sub jdfunc ''''''''''''''''''''''''''' local eps, a, b, c, d, e, fa, fb, fcc, tol1 local xm, p, q, r, s, xmin, tmp eps = 2.23e-16 e = 0.0 a = x1 b = x2 jdfunc(a, fa) jdfunc(b, fb) fcc = fb for iter% = 1 to 50 if (fb * fcc > 0.0) then c = a fcc = fa d = b - a e = d end if if (abs(fcc) < abs(fb)) then a = b b = c c = a fa = fb fb = fcc fcc = fa end if tol1 = 2.0 * eps * abs(b) + 0.5 * tol xm = 0.5 * (c - b) if (abs(xm) <= tol1 or fb = 0) then exit for if (abs(e) >= tol1 and abs(fa) > abs(fb)) then s = fb / fa if (a = c) then p = 2.0 * xm * s q = 1.0 - s else q = fa / fcc r = fb / fcc p = s * (2.0 * xm * q * (q - r) - (b - a) * (r - 1.0)) q = (q - 1.0) * (r - 1.0) * (s - 1.0) end if if (p > 0) then q = -q p = abs(p) xmin = abs(e * q) tmp = 3.0 * xm * q - abs(tol1 * q) if (xmin < tmp) then xmin = tmp if (2.0 * p < xmin) then e = d d = p / q else d = xm e = d end if else d = xm e = d end if a = b fa = fb if (abs(d) > tol1) then b = b + d else b = b + sgn(xm) * tol1 end if jdfunc(b, fb) next iter% froot = fb xroot = b end sub '''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''' sub julian(month, day, year, jday) ' Gregorian date to julian day subroutine ' input ' month = calendar month ' day = calendar day ' year = calendar year (all four digits) ' output ' jday = julian day ' special notes ' (1) calendar year must include all digits ' (2) will report October 5, 1582 to October 14, 1582 ' as invalid calendar dates and exit ''''''''''''''''''''''''''''''''''''''''' local a, b, c, m, y y = year m = month b = 0.0 c = 0.0 if (m <= 2.0) then y = y - 1.0 m = m + 12.0 end if if (y < 0.0) then c = -0.75 if (year < 1582.0) then ' null elseif (year > 1582.0) then a = fix(y / 100.0) b = 2.0 - a + fix(a / 4.0) elseif (month < 10.0) then ' null elseif (month > 10.0) then a = fix(y / 100.0) b = 2.0 - a + fix(a / 4.0) elseif (day <= 4.0) then ' null elseif (day > 14.0) then a = fix(y / 100.0) b = 2.0 - a + fix(a / 4.0) else print "this date does not exist!!" exit end if jday = fix(365.25 * y + c) + fix(30.6001 * (m + 1.0)) + day + b + 1720994.5 end sub '''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''' sub gdate (jday, month, day, year) ' Julian day to Gregorian date subroutine ' input ' jday = julian day ' output ' month = calendar month ' day = calendar day ' year = calendar year '''''''''''''''''''''''' local a, b, c, d, e, f, z, alpha z = fix(jday + 0.5) f = jday + 0.5 - z if (z < 2299161) then a = z else alpha = fix((z - 1867216.25) / 36524.25) a = z + 1.0 + alpha - fix(alpha / 4.0) end if b = a + 1524.0 c = fix((b - 122.1) / 365.25) d = fix(365.25 * c) e = fix((b - d) / 30.6001) day = b - d - fix(30.6001 * e) + f if (e < 13.5) then month = e - 1.0 else month = e - 13.0 end if if (month > 2.5) then year = c - 4716.0 else year = c - 4715.0 end if end sub ''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''' sub utc2tdb (jdutc, tai_utc, jdtdb) ' convert UTC julian date to TDB julian date ' input ' jdutc = UTC julian day ' tai_utc = TAI-UTC (seconds) ' output ' jdtdb = TDB julian day ' Reference Frames in Astronomy and Geophysics ' J. Kovalevsky et al., 1989, pp. 439-442 ''''''''''''''''''''''''''''''''''''''''' local corr, jdtdt, t ' TDT julian date corr = (tai_utc + 32.184) / 86400.0 jdtdt = jdutc + corr ' time argument for correction t = (jdtdt - 2451545.0) / 36525.0 ' compute correction in microseconds corr = 1656.675 * sin(dtr * (35999.3729 * t + 357.5287)) corr = corr + 22.418 * sin(dtr * (32964.467 * t + 246.199)) corr = corr + 13.84 * sin(dtr * (71998.746 * t + 355.057)) corr = corr + 4.77 * sin(dtr * ( 3034.906 * t + 25.463)) corr = corr + 4.677 * sin(dtr * (34777.259 * t + 230.394)) corr = corr + 10.216 * t * sin(dtr * (35999.373 * t + 243.451)) corr = corr + 0.171 * t * sin(dtr * (71998.746 * t + 240.98 )) corr = corr + 0.027 * t * sin(dtr * ( 1222.114 * t + 194.661)) corr = corr + 0.027 * t * sin(dtr * ( 3034.906 * t + 336.061)) corr = corr + 0.026 * t * sin(dtr * ( -20.186 * t + 9.382)) corr = corr + 0.007 * t * sin(dtr * (29929.562 * t + 264.911)) corr = corr + 0.006 * t * sin(dtr * ( 150.678 * t + 59.775)) corr = corr + 0.005 * t * sin(dtr * ( 9037.513 * t + 256.025)) corr = corr + 0.043 * t * sin(dtr * (35999.373 * t + 151.121)) ' convert corrections to days corr = 0.000001 * corr / 86400.0 ' TDB julian date jdtdb = jdtdt + corr end sub '''''''''''''''''''''''''''' '''''''''''''''''''''''''''' sub findleap(jday, leapsecond) ' find number of leap seconds for utc julian day ' input ' jday = utc julian day ' input via global ' jdleap = array of utc julian dates ' leapsec = array of leap seconds ' output ' leapsecond = number of leap seconds '''''''''''''''''''''''''''''''''''''' if (jday <= jdleap(1)) then ' date is <= 1972; set to first data element leapsecond = leapsec(1) exit sub end if if (jday >= jdleap(27)) then ' date is >= end of current data ' set to last data element leapsecond = leapsec(27) exit sub end if ' find data within table for i% = 1 to 26 if (jday >= jdleap(i%) and jday < jdleap(i% + 1)) then leapsecond = leapsec(i%) exit sub end if next i% end sub ''''''''''''''''''''''''' ''''''''''''''''''''''''' function modulo(x) as float ' modulo 2 pi function '''''''''''''''''''''' local a a = x - pi2 * fix(x / pi2) if (a < 0.0) then a = a + pi2 end if modulo = a end function ''''''''''''''''''''''''''' ''''''''''''''''''''''''''' function atan3(a, b) as float ' four quadrant inverse tangent function ' input ' a = sine of angle ' b = cosine of angle ' output ' atan3 = angle (0 =< atan3 <= 2 * pi; radians) '''''''''''''''''''''''''''''''''''''''''''''''' local c if (abs(a) < 1.0e-10) then atan3 = (1.0 - sgn(b)) * pidiv2 exit function else c = (2.0 - sgn(a)) * pidiv2 endif if (abs(b) < 1.0e-10) then atan3 = c exit function else atan3 = c + sgn(a) * sgn(b) * (abs(atn(a / b)) - pidiv2) endif end function |
Leave a Reply