June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,23 @@
10 ' Horizontal sundial calculations
20 PRINT "Enter latitude => ";
30 INPUT LAT
40 PRINT "Enter longitude => ";
50 INPUT LNG
60 PRINT "Enter legal meridian => ";
70 INPUT REF
80 PRINT
90 LET PI = 4 * ATN(1)
100 LET SLAT = SIN(LAT * PI / 180)
110 PRINT " sine of latitude: "; USING "#.##^^^^"; SLAT
120 PRINT " diff longitude: "; USING "####.###"; LNG - REF
130 PRINT
140 PRINT "Hour, sun hour angle, dial hour line angle from 6am to 6pm"
150 FOR H% = -6 TO 6
160 LET HRA = 15 * H%
170 LET HRA = HRA - (LNG - REF): ' correct for longitude difference
180 LET HLA = ATN(SLAT * TAN(HRA * PI / 180)) * 180 / PI
190 PRINT "HR="; USING "+##"; H%;
200 PRINT "; HRA="; USING "+###.###"; HRA;
210 PRINT "; HLA="; USING "+###.###"; HLA
220 NEXT H%
230 END

View file

@ -0,0 +1,49 @@
MODULE SunDial;
FROM STextIO IMPORT
WriteString, WriteLn, SkipLine;
FROM SRealIO IMPORT
ReadReal, WriteFixed, WriteFloat;
FROM SWholeIO IMPORT
WriteInt;
FROM RealMath IMPORT
sin, pi, arctan, tan;
VAR
Lat, Slat, Lng, Ref: REAL;
Hour: INTEGER;
HourAngle, HourLineAngle: REAL;
BEGIN
WriteString("Enter latitude => ");
ReadReal(Lat);
SkipLine;
WriteString("Enter longitude => ");
ReadReal(Lng);
SkipLine;
WriteString("Enter legal meridian => ");
ReadReal(Ref);
SkipLine;
WriteLn;
Slat := sin(Lat * pi / 180.0);
WriteString(" sine of latitude: ");
WriteFloat(Slat, 2, 8);
WriteLn;
WriteString(" diff longitude: ");
WriteFixed(Lng - Ref, 3, 1);
WriteLn;
WriteLn;
WriteString("Hour, sun hour angle, dial hour line angle from 6am to 6pm");
WriteLn;
FOR Hour := -6 TO 6 DO
HourAngle := FLOAT(15 * Hour);
HourAngle := HourAngle - (Lng - Ref); (* correct for longitude difference *)
HourLineAngle := arctan(Slat * tan(HourAngle * pi / 180.0)) * 180.0 / pi;
WriteString("HR=");
WriteInt(Hour, 3);
WriteString("; HRA=");
WriteFixed(HourAngle, 3, 8);
WriteString("; HLA=");
WriteFixed(HourLineAngle, 3, 8);
WriteLn;
END;
END SunDial.

View file

@ -3,7 +3,7 @@ numeric digits 60 /*in case sundial is in polar r
parse arg lat lng . /*obtain optional arguments from the CL*/
/* ┌───────────◄ None specified? Then use the default*/
/* │ of Jules Verne's Lincoln Island, */
/* ↓ aka Ernest Legouve Reed. */
/* ↓ aka Ernest Legouve Reef. */
if lat=='' | lat=="," then lat= -4.95 /*Not specified? Then use the default.*/
if lng=='' | lng=="," then lng= -150.5 /* " " " " " " */
mer=format(lng/15, , 0) * 15 /*calculate legal meridian longitude. */
@ -18,7 +18,7 @@ L=max(length(lat), length(lng), length(mer) ) /*find maximum length of three
indent=left('', 30) /*make prettier: indented presentation.*/
say indent center(' ', w1) center("sun hour", w2) center('dial hour' , w3)
say indent center('hour', w1) center("angle" , w2) center('line angle', w3)
call sep /*to help a one-eyed pirate's eyeball. */
call sep /*to help a oneeyed pirate's eyeball. */
do h=-6 to 6 /*Okey dokey then, now let's show stuff*/
select
when abs(h)==12 then hc='midnight' /*Holy smokes! Above the arctic circle.*/
@ -28,9 +28,10 @@ call sep /*to help a one-eyed pirate's e
end /*select*/
hra=15 * h - lng + mer /*calculate sun hour angle (in degrees)*/
hla=r2d( Atan(sineLat * tan( d2r(hra)))) /*this is the heavy lifting calculation*/
if abs(hra)>90 then hla=hla + 180*sign(hra*lat) /*adjust for negative angle. */
say indent center(hc, w1) right(format(hra, ,1), w2) right(format(hla, ,1), w3)
end /*h*/
call sep /*to help a one-eyed pirate's eyeball. */
call sep /*to help a oneeyed pirate's eyeball. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
pi: pi= 3.1415926535897932384626433832795028841971693993751058209749445923078; return pi
@ -48,7 +49,7 @@ Acos: procedure; arg x; if x<-1 | x>1 then call AcosErr; return .5 * pi()
Atan: procedure; parse arg x; if abs(x)=1 then return pi()/4*x; return Asin(x/sqrt(1+x*x))
/*──────────────────────────────────────────────────────────────────────────────────────*/
Asin: procedure; parse arg x; if x<-1 | x>1 then call AsinErr; s=x*x
if abs(x)>=sqrt(2)*.4 then return sign(x) * Acos(sqrt(1-s)); z=x; o=x; p=z
if abs(x)>=sqrt(2)*.5 then return sign(x) * Acos(sqrt(1-s)); z=x; o=x; p=z
do j=2 by 2; o=o*s*(j-1)/j; z=z+o/(j+1); if z=p then leave; p=z; end; return z
/*──────────────────────────────────────────────────────────────────────────────────────*/
sin: procedure; parse arg x; x=r2r(x); numeric fuzz min(5, digits() - 3)

View file

@ -0,0 +1,27 @@
# Project : Horizontal sundial calculations
# Date : 2017/10/24
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
load "stdlib.ring"
pi = 22/7
decimals(3)
latitude = -4.95
longitude = -150.5
meridian = -150.0
see "enter latitude (degrees): " + latitude + nl
see "enter longitude (degrees): " + longitude + nl
see "enter legal meridian (degrees): " + meridian + nl
see "time " + " sun hour angle" + " dial hour line angle" + nl
for hour = 6 to 18
hra = 15*hour - longitude + meridian - 180
hla = 180/pi*(atan(sin(pi/180*latitude) * tan(pi/180*hra)))
if fabs(hra) > 90
hla = hla + 180 * sign(hra * latitude)
ok
see "" + hour + " " + hra + " " + hla + nl
next