//--delphi function sn(x: double): double; begin sn := sin(x*pi/180); end; function cs(x: double): double; begin cs := cos(x*pi/180); end; function tn(x: double): double; begin tn := tan(x*pi/180); end; function asn(x: double): double; begin asn := arcsin(x)*180/pi; end; function atn2(y, x: double): double; var tmp: double; begin if x=0 then begin if y>=0 then atn2 := 90 else atn2 := -90; end else begin tmp := arctan(y/x)*180/pi; if x<0 then tmp := tmp + 180; atn2 := tmp; end; end; procedure TForm1.bt_calcClick(Sender: TObject); var phi, lambda, JD, JD0, n, L, g, ecLon, eps, alpha, delta, T0, thG, th, A, h, R, hr: double; code: integer; outstr: string; begin val(trim(ed_phi.text), phi, code); val(trim(ed_lambda.text), lambda, code); val(trim(ed_JD.text), JD, code); n := JD - 2451545; L := 280.460 + 0.9856474*n; while L>=360 do L := L-360; // besser: L := 360*frac(L/360); while L < 0 do L := L + 360; str(L:9:5, outstr); ed_L.text := outstr; g := 357.528 + 0.9856003*n; while g>=360 do g := g - 360; // besser: g := 360*frac(g/360); while g < 0 do g := g + 360; str(g:9:5, outstr); ed_g.text := outstr; ecLon := L + 1.915 * sn(g) + 0.020*sn(2*g); while ecLon>=360 do ecLon := ecLon - 360; // besser: ecLon := 360*frac(ecLon/360); while ecLon < 0 do ecLon := ecLon + 360; str(ecLon:9:5, outstr); ed_ecLon.text := outstr; eps := 23.439 - 0.0000004*n; str(eps:9:5, outstr); ed_eps.text := outstr; alpha := atn2( cs(eps)*sn(ecLon), cs(ecLon)); str(alpha:9:5, outstr); ed_alpha.text := outstr; delta := asn(sn(eps)*sn(ecLon)); str(delta:9:5, outstr); ed_delta.text := outstr; JD0 := int(JD-0.5)+0.5; str(JD0:9:1, outstr); ed_JD0.text := outstr; T0 := (JD0 - 2451545)/36525; str(T0:9:5, outstr); ed_T0.text := outstr; thG := 2400.05134*T0; thG := frac(thG/24)*24; thG := thG + 6.697376 + 1.002738*(JD-JD0)*24; thG := frac(thG/24)*24; while thG<0 do thG := thG+24; str(thG:9:5, outstr); ed_thG.text := outstr; th := thG*15 + lambda; while th>=360 do th := th - 360; // besser: th := 360*frac(th/360); while th< 0 do th := th + 360; str(th:9:5, outstr); ed_th.text := outstr; A := atn2(cs(delta)*sn(th-alpha), cs(delta)*cs(th-alpha)*sn(phi)-sn(delta)*cs(phi)); str(A:9:5, outstr); ed_A.text := outstr; h := asn(cs(delta)*cs(th-alpha)*cs(phi)+sn(delta)*sn(phi)); str(h:9:5, outstr); ed_h.text := outstr; R := 1.02 / tn(h + 10.3/(h+5.11)); hr := h + R/60; str(hr:9:5, outstr); ed_hr.text := outstr; end;