-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSundial.en
169 lines (169 loc) · 7.51 KB
/
Sundial.en
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
% * Projekt Untere Bütschen
>load "astro.e";
>e:=23.44°; Dek7:=asin(sin(e)*sin([-90:30:90]°)); deg(Dek7)
[-23.44, -20.151, -11.4723, 0, 11.4723, 20.151, 23.44]
>lat:= 47.41265°; lon:= -7.6958595°; wa:= 18.9°; deg([90°+wa,wa-90°])
[108.9, -71.1]
% Erhebungs-, Substilarwinkel sowie Stundenwinkel-Differenz
>g:=asin(cos(lat)*cos(wa)); f:=atan2(tan(lat),-sin(wa)); ...
>tsub:=atan2(sin(lat),tan(wa));
>[deg(g), deg(f), deg(tsub-90°), deg(90°+tsub)]
[39.8089, -16.5796, -65.0602, 114.94]
% tau mit Mittlerer Ortszeit, Fusspunkt-Koordinaten
>tau:=([-120:15:150]-15-deg(lon))°; FD:=80; HD=FD*sin(g); ...
>short(HD), F:=HD*[sin(f),cos(f)]/tan(g)
51.218
[-17.5359, 58.8997]
>function Dekli(t) ....
$h=sun(t);
$return h[2];
$endfunction
% Wandflucht morgens: Aufgang vor Fassade
>{t,d}=HorAeq(-90+deg(wa),0,); [t, d]
[-75.852, -12.662]
>t1=secant("Dekli(x)-d",day(2017,3,24)); t2=secant("Dekli(x)-d",day(2017,9,20));
>printday(t1), printday(t2)
2017-02-15 01:35:03
2017-10-26 16:27:06
% Wandflucht abends: Sonnenuntergang hinter Fassade
>{t,d}=HorAeq(90+deg(wa),0,); [t, d]
[104.148, 12.662]
>t1=secant("Dekli(x)-d",day(2017,5,21)); t2=secant("Dekli(x)-d",day(2017,7,21));
>printday(t1), printday(t2)
2017-04-23 10:15:08
2017-08-19 08:29:20
>function ZifferblattMatrix(f=lat,a=wa,i=0°)
$Z=zeros(3,3);
$Z[1,1]=sin(f)*sin(a); Z[1,2]=-cos(a); Z[1,3]=-cos(f)*sin(a);
$Z[2,1]=cos(f)*cos(i)-sin(f)*cos(a)*sin(i); Z[2,2]=-sin(a)*sin(i);
$Z[2,3]=cos(f)*cos(a)*sin(i)+sin(f)*cos(i);
$$Z[3,1]=cos(f)*sin(i)+sin(f)*cos(a)*cos(i); Z[3,2]=sin(a)*cos(i);
$Z[3,3]=-cos(f)*cos(a)*cos(i)+sin(f)*sin(i);
$$return Z
$endfunction
>D:=ZifferblattMatrix()
0.238483 -0.946085 -0.219199
0.676713 0 0.736247
0.696552 0.323917 -0.640229
>{theta,psi,r}:=polar(D[1,3],D[2,3],D[3,3]); [r, deg(theta), deg(psi)]
[1, 106.58, -39.8089]
% Umwandlung in kartesische Koordinaten
>function KartKoo(tau,delta)
$## wandelt Horizontal- und Vertikalwinkel in kart. Koordinaten um
$return cos(delta)*cos(tau)_cos(delta)*sin(tau)_sin(delta);
$endfunction
>n:=size(Dek7)[2]; Mat:=[]; for i=1:n; Z:=(D.KartKoo(tau,Dek7[i]))'; ...
>keep:= nonzeros(Z[,3]>0); Z:=Z[keep]; z:=-HD*Z[,1:2]/Z[,3]; ...
>Mat:=Mat_(i|tau[keep]'|z|Z); end;
% Topografischer Horizont
>..Sky:=readmatrix("Buetschen_SkyFDot.rpt"); ...
>open("Horizont.csv","w"); Sky:=Sky[55:146]; Sky[,1]:=Sky[,1]-180; ...
>Dhor:= ZifferblattMatrix(90°,,); ...
>Z:=(Dhor.KartKoo(Sky[,1]°',Sky[,2]°'))'; z:=-HD*Z[,1:2]/Z[,3]; ...
>writematrix(Sky[,1]|Z|z,separator=";");
% Horizontmarkierungen
>..Z:=(Dhor.KartKoo([-60:15:105]°,0))'; z:=-HD*Z[,1:2]/Z[,3]; ...
>writematrix([-60:15:105]'|Z|z,separator=";"); ...
>close();
% Transformation auf Substilare
%% und Achsabschnitte
>Z:=(D.KartKoo(tsub,Dek7))'; z:=-HD*Z[,1:2]/Z[,3]; ...
>X:=Mat[,[3:4]]-z[4];
>Df:=[cos(f),sin(f);-sin(f),cos(f)]
0.958424 -0.285347
0.285347 0.958424
>Mat:=Mat|(X.Df);
>AxeSub:=Df'.(z-z[4])';
% Parameterschätzung
>Par=[]; function hyperbola(x,p):=p[1]/p[2]*sqrt(x^2+p[2]^2);
>for i=1:n; xdata:=Mat[nonzeros(Mat[,1]==i),8]'; ...
>ydata:=Mat[nonzeros(Mat[,1]==i),9]'; ...
>p:=modelfit("hyperbola",[27.6,54],xdata,ydata); ...
>fs:=ydata-hyperbola(xdata,p); ...
>dev:=sqrt(sum(fs^2)/(size(xdata)[2]-size(p)[2])); ...
>Par:=Par_(p|dev); end;
% Test
>plot2d(xdata,ydata,>points); plot2d("hyperbola(x,p)",>add,color=red)
>writetable((xdata_ydata_fs)')
-565.38 -360.6 2.64
-154.18 -118.51 -3.38
-73.43 -77.68 -0.97
-33.29 -63.38 1.16
-4.09 -58.99 2.07
23.98 -61.29 1.58
59.3 -71.87 -0.23
121.38 -100.92 -2.77
327.53 -218.56 -2.35
>Par:=Par'; Par:=Par_(sign(Par[1])*sqrt(Par[1]^2+Par[2]^2)); Par:=Par_(Par[2]^2/Par[1]); ...
>Par:=Par_AxeSub[2]; Par:=Par';
>writetable(Par,labc=["a","b","Dev","e","p","AxeSub"]);
a b Dev e p AxeSub
24.65 42.16 4.1 48.84 72.09 27.64
21.66 43.33 4.35 48.44 86.67 24.39
14.63 55.98 0.53 57.86 214.23 15.07
0 77.34 0 77.341.11742e+17 0
-21.82 80.55 0.81 -83.46 -297.3 -21.2
-46.94 88.82 1.17 -100.46 -168.07 -45.88
-61.01 96.33 2.41 -114.02 -152.1 -58.92
>plot2d(Mat[,8]',Mat[,9]',r=250,style="...",>points); ...
>plot2d(AxeSub[1],AxeSub[2],>points,color=red,style="+",>add); ...
>plot2d(zeros(n),Par[,4]',>points,>add):
%image% Sundial-001.png
>load "geometry.e"
Numerical and symbolic geometry.
>p=lineWithDirection(F,[cos(lat),sin(lat)]);
>h=lineThrough([0,0],[1000,0]); H=lineIntersection(p,h)
[-71.673, 0]
>q=lineWithDirection(H,[sin(lat),-cos(lat)]);
>M=lineIntersection(q,lineWithDirection(F,[0,-100]));
>K=circleWithCenter(M,distance(M,H))
[-17.5359, -49.7595, 73.5312]
>s=lineThrough(F,[0,0]);
>Z=lineCircleIntersections(s,K)
[31.206, -104.815]
% Darstellung
>tm=Mat[nonzeros(Mat[,1]==7),[3:4]]';
>plot2d(tm[1],tm[2],a=-200,b=200,c=-350,d=50,>points,style="...",color=red);
>for i=1:n; tm:=Mat[nonzeros(Mat[,1]==i),[3:4]]'; plot2d(tm[1],tm[2],>add); end;
>plotPoint(F,"F"); plotPoint(M,"M"); plotPoint(H,"H"); plotPoint(Z,"Z"); plotSegment(F,[0,0],""):
%image% Sundial-002.png
>zsub:=atan(tan(tau-tsub)*sin(g)); z:=zsub-f;
>ep:=acos(sin(lat)*cos(z)-cos(lat)*sin(z)*sin(-wa));
>tmp:=(tau+lon+15°)/15_z_zsub_ep; tmp:=tmp';
>size(tmp)
[19, 4]
>writetable(deg(tmp[5:17]),dc=1,labc=["t","zM","zS","eps"])
t zM zS eps
-4 103.1 86.5 87.3
-3 -53.9 -70.5 75.2
-2 -34 -50.6 60.8
-1 -18.1 -34.7 50.8
0 -5.4 -22 44.6
1 5.3 -11.2 41.1
2 15.1 -1.4 39.8
3 24.8 8.2 40.5
4 35.2 18.6 43.3
5 47.2 30.6 48.6
6 62 45.4 57.4
7 80.7 64.1 70.4
8 103.1 86.5 87.3
>FE:=FD*cos(Dek7)/cos(ep'+Dek7);
>writetable(FE[5:17],dc=1,>fixed, ...
>labr=deg(tmp[[5:17],1]),labc=round(deg(Dek7),2))
-23.44 -20.15 -11.47 0 11.47 20.15 23.44
-4 166.7 193.5 320.4 1704.7 -513.5 -250.3 -207.2
-3 118.5 131.0 176.9 312.4 1335.3 -811.1 -490.8
-2 92.3 99.0 120.3 164.0 257.5 477.7 731.9
-1 82.7 87.3 101.4 126.7 168.7 230.5 270.8
0 78.7 82.5 93.6 112.3 140.4 175.9 196.1
1 77.0 80.4 90.2 106.2 129.0 156.2 170.8
2 76.5 79.8 89.1 104.2 125.4 150.1 163.2
3 76.8 80.1 89.7 105.2 127.3 153.3 167.2
4 78.0 81.7 92.3 109.9 135.9 167.9 185.7
5 81.1 85.4 98.4 121.0 157.2 207.4 238.3
6 88.5 94.3 112.7 148.4 217.3 347.7 459.8
7 107.6 117.5 152.0 238.7 555.9 -7534.5 -1090.3
8 166.7 193.5 320.4 1704.7 -513.5 -250.3 -207.2
>HE:=sqrt(Mat[,3]^2+Mat[,4]^2); DE:=sqrt(HD^2+HE^2); psi:=acos(HE/DE);
>Mat:=Mat|HE|DE|psi; writematrix(Mat,"Vertikaluhr.csv",separator=";");
>