#!"C:\apache\xampp\perl\bin\perl.exe" #Translated from BASIC by basic2pl ############################################################################## # Main program # my(%FORM); # Hash FORM wird initialisiert foreach $pair (@ARGV) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } @ARGV = (); @Gosub_Stack = (); $b5=$FORM{'lat'}; $l5=$FORM{'lon'}; $h=-$FORM{'tz'}; $y=$FORM{'year'}; $m=$FORM{'month'}; $d=$FORM{'day'}; L20: push @Gosub_Stack, "AL20"; goto L300; AL20: ; ; # print "Enter your Latitude positive numbers North of equator, negative for South","\n"; ; # print "Longitude negative for West of Greenwich, positive for East","\n"; ; #L30: print "Lat, Long (deg)" . "? "; ; # $input_tmp = <>; ; # chomp($input_tmp); ; # ($b5, $l5) = split(/\s*,\s*/, $input_tmp); ; # print "enter your difference in time from Greenwich, positive numbers going East","\n"; ; #L40: print "Time zone (hrs)" . "? "; ; # $input_tmp = <>; ; # chomp($input_tmp); ; # $h = $input_tmp; L50: $l5 = $l5/360; $z0 = $h/24; L60: push @Gosub_Stack, "AL60"; goto L1170; AL60: ; $t = ($j-2451545)+$f; L70: $tt = $t/36525+1; L80: ; # from 1900.0 L90: push @Gosub_Stack, "AL90"; goto L410; AL90: ; $t = $t+$z0; L100: ; # L110: ; # Get Sun's Position L120: push @Gosub_Stack, "AL120"; goto L910; AL120: ; $a[1] = $a5; $d[1] = $d5; L130: $t = $t+1; L140: push @Gosub_Stack, "AL140"; goto L910; AL140: ; $a[2] = $a5; $d[2] = $d5; L150: if ($a[2] < $a[1]) { $a[2] = $a[2]+$p2; } L160: $z1 = $dr*90.833; ; # ' Zenith dist. L170: $s = sin($b5*$dr); $c = cos($b5*$dr); L180: $z = cos($z1); $m8 = 0; $w8 = 0; print("", "\n"); L190: $a0 = $a[1]; $d0 = $d[1]; L200: $da = $a[2]-$a[1]; $dd = $d[2]-$d[1]; L210: $c0 = 0; $step_for_c0 = 1; $limit_for_c0 = 23; do { L220: $p = ($c0+1)/24; L230: $a2 = $a[1]+$p*$da; $d2 = $d[1]+$p*$dd; L240: push @Gosub_Stack, "AL240"; goto L490; AL240: ; L250: $a0 = $a2; $d0 = $d2; $v0 = $v2; L260: $c0 += $step_for_c0; } until ($step_for_c0 > 0 ? $c0 > $limit_for_c0 : $c0 < $limit_for_c0); L270: push @Gosub_Stack, "AL270"; goto L820; AL270: ; ; # ' Special msg? L280: exit; L290: ; # L300: ; # Constants L310: ; L320: $p1 = 3.14159265; $p2 = 2*$p1; L330: $dr = $p1/180; $k1 = 15*$dr*1.0027379; L340: $s_str = "#1#";#Sunset L350: $r_str = "#2#";#Sunrise L360: $m1_str = "#3#";#No sunrise this date L370: $m2_str = "#4#";#No sunset this date L380: $m3_str = "#5#";#Sun down all day L390: $m4_str = "#6#";#Sun up all day L400: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L410: ; # LST at 0h zone time L420: $t0 = $t/36525; L430: $s = 24110.5+8640184.813*$t0; L440: $s = $s+86636.6*$z0+86400*$l5; L450: $s = $s/86400; $s = $s-int($s); L460: $t0 = $s*360*$dr; L470: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L480: ; # L490: ; # Test an hour for an event L500: $l0 = $t0+$c0*$k1; $l2 = $l0+$k1; L510: $h0 = $l0-$a0; $h2 = $l2-$a2; L520: $h1 = ($h2+$h0)/2; ; # Hour angle, L530: $d1 = ($d2+$d0)/2; ; # declination, L540: ; # at half hour L550: if ($c0 > 0) { goto L570; } L560: $v0 = $s*sin($d0)+$c*cos($d0)*cos($h0)-$z; L570: $v2 = $s*sin($d2)+$c*cos($d2)*cos($h2)-$z; L580: if (sgn($v0) == sgn($v2)) { goto L800; } L590: $v1 = $s*sin($d1)+$c*cos($d1)*cos($h1)-$z; L600: $a = 2*$v2-4*$v1+2*$v0; $b = 4*$v1-3*$v0-$v2; L610: $d = $b*$b-4*$a*$v0; if ($d < 0) { goto L800; } L620: $d = sqrt($d); L630: if ($v0 < 0 && $v2 > 0) { print($r_str); } L640: if ($v0 < 0 && $v2 > 0) { $m8 = 1; } L650: if ($v0 > 0 && $v2 < 0) { print($s_str); } L660: if ($v0 > 0 && $v2 < 0) { $w8 = 1; } L670: $e = (-$b+$d)/(2*$a); L680: if ($e > 1 || $e < 0) { $e = (-$b-$d)/(2*$a); } L690: $t3 = $c0+$e+1/120; ; # Round off L700: $h3 = int($t3); $m3 = int(($t3-$h3)*60); L701: ; # PRINT USING "##:##";H3;M3; $zeit = sprintf ("%02d:%02d|", $h3, $m3); print($zeit); L720: $h7 = $h0+$e*($h2-$h0); L730: $n7 = -cos($d1)*sin($h7); L740: $d7 = $c*sin($d1)-$s*cos($d1)*cos($h7); L750: $az = atan2($n7,$d7)/$dr; L760: if ($d7 < 0) { $az = $az+180; } L770: if ($az < 0) { $az = $az+360; } L780: if ($az > 360) { $az = $az-360; } L781: ; # PRINT USING ", azimuth ###.#";AZ ; # L790: print(", azimuth ", $az,' ', "\n"); L790: $azimuth=sprintf("%.3f", $az); print ($azimuth,"°|"); L800: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L810: ; # L820: ; # Special-message routine L830: if ($m8 == 0 && $w8 == 0) { goto L870; } L840: if ($m8 == 0) { print($m1_str, "\n"); } L850: if ($w8 == 0) { print($m2_str, "\n"); } L860: goto L890; L870: if ($v2 < 0) { print($m3_str, "\n"); } L880: if ($v2 > 0) { print($m4_str, "\n"); } L890: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L900: ; # L910: ; # Fundamental arguments L920: ; # (Van Flandern & L930: ; # Pulkkinen, 1979) L940: $l = 0.779072+0.00273790931*$t; L950: $g = 0.993126+0.0027377785*$t; L960: $l = $l-int($l); $g = $g-int($g); L970: $l = $l*$p2; $g = $g*$p2; L980: $v = 0.39785*sin($l); L990: $v = $v-0.01*sin($l-$g); L1000: $v = $v+0.00333*sin($l+$g); L1010: $v = $v-0.00021*$tt*sin($l); L1020: $u = 1-0.03349*cos($g); L1030: $u = $u-0.00014*cos(2*$l); L1040: $u = $u+8e-05*cos($l); L1050: $w = -0.0001-0.04129*sin(2*$l); L1060: $w = $w+0.03211*sin($g); L1070: $w = $w+0.00104*sin(2*$l-$g); L1080: $w = $w-0.00035*sin(2*$l+$g); L1090: $w = $w-8e-05*$tt*sin($g); L1100: ; # L1110: ; # Compute Sun's RA and Dec L1120: $s = $w/sqrt($u-$v*$v); L1130: $a5 = $l+atan2($s/sqrt(1-$s*$s),1); L1140: $s = $v/sqrt($u); $d5 = atan2($s/sqrt(1-$s*$s),1); ; # $r5 commented out, perl complains not used anywhere else ; ; # L1150: $r5 = 1.00021*sqrt($u); L1160: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L1165: ; # L1170: ; # Calendar --> JD ; #L1180: print "Year, Month, Day" . "? "; ; # $input_tmp = <>; ; # chomp($input_tmp); ; # ($y, $m, $d) = split(/\s*,\s*/, $input_tmp); L1190: $g = 1; if ($y < 1583) { $g = 0; } L1200: $d1 = int($d); $f = $d-$d1-0.5; L1210: $j = -int(7*(int(($m+9)/12)+$y)/4); L1220: if ($g == 0) { goto L1260; $s = sgn($m-9); L1224: $a = abs($m-9); } L1230: ; # S=SGN M-9: A=ABS(M-9) L1240: $j3 = int($y+$s*int($a/7)); L1250: $j3 = -int((int($j3/100)+1)*3/4); L1260: $j = $j+int(275*$m/9)+$d1+$g*$j3; L1270: $j = $j+1721027+2*$g+367*$y; L1280: if ($f >= 0) { goto L1300; } L1290: $f = $f+1; $j = $j-1; L1300: $Return_tmp = pop @Gosub_Stack; goto $Return_tmp; L1310: ; # L1320: ; # This program by Roger W. Sinnott calculates the times of sunrise L1330: ; # and sunset on any date, accurate to the minute within several L1340: ; # centuries of the present. It correctly describes what happens in the L1350: ; # arctic and antarctic regions, where the Sun may not rise or set on L1360: ; # a given date. Enter north latitudes positive, west longitudes L1370: ; # negative. For the time zone, enter the number of hours west of L1380: ; # Greenwich (e.g., 5 for EST, 4 for EDT). The calculation is L1390: ; # discussed in Sky & Telescope for August 1994, page 84. sub sgn { return $_[0] == 0 ? 0 : $_[0] < 0 ? -1 : 1; }