Private Function range360(x)
range360 = x - 360 * Int(x / 360)
End Function



Function dgmond(jahr As Integer, monat As Integer, tag As Integer, Lnge As Double, Zeitzone As Integer) As Double


    Dim nm As Double, im As Double, wm As Double, am As Double, ecm As Double, _
    Mm As Double, em As Double, Ms As Double, ws As Double, xv As Double, _
    yv As Double, vm As Double, rm As Double, x As Double, Y As Double, _
    Z As Double, lon As Double, lat As Double, ls As Double, lm As Double, _
    dm As Double, F As Double, dlong As Double, dlat As Double, AzimutN As Double, jdnull As Double, jd As Double


Breite = 35

If monat > 2 Then
    monat = monat
    jahr = jahr
    End If
    
    If monat <= 2 Then
    monat = monat + 12
    jahr = jahr - 1
    End If
    
    aaaaa = Fix(jahr / 100)
    bbbbb = 2 - aaaaa + Fix(aaaaa / 4)
    
    jdnull = Fix(365.25 * (jahr + 4716)) + Fix(30.6001 * (monat + 1)) + tag + bbbbb - 1524.5
    jdnull = jdnull - Zeitzone / 24


jd = jdnull


nn = 0
For ii = 0 To 4320 Step 1
aaaaaa = ii / 4320

jd = jdnull + aaaaaa




kk = 3.14159265358979 / 180
d = jd - 2451543.5
jdx = jd


  
    nm = range360(125.1228 - 0.0529538083 * d)
    im = 5.1454
    wm = range360(318.0634 + 0.1643573223 * d)
    am = 60.2666  '(Earth radii)
    ecm = 0.0549
    Mm = range360(115.3654 + 13.0649929509 * d) 'M
    
    Enull = Mm + (180 / 3.14159265358979) * ecm * sin(Mm * 3.14159265358979 / 180) * (1 + ecm * Cos(Mm * 3.14159265358979 / 180))
    
    Eeins = Enull - (Enull - (180 / 3.14159265358979) * ecm * sin(Enull * 3.14159265358979 / 180) - Mm) / (1 - ecm * Cos(Enull * 3.14159265358979 / 180))
    
    Ezwei = Eeins - (Eeins - (180 / 3.14159265358979) * ecm * sin(Eeins * 3.14159265358979 / 180) - Mm) / (1 - ecm * Cos(Eeins * 3.14159265358979 / 180))
    
    xx = am * (Cos(Ezwei * 3.14159265358979 / 180) - ecm)
    yy = am * Sqr(1 - ecm * ecm) * sin(Ezwei * 3.14159265358979 / 180)
     
    
    
    xv = xx
    yv = yy
    
     vv = Atn(yy / xx) * 180 / 3.14159265358979
     If xx < 0 Then
     vv = 180 + vv
     End If
     vv = range360(vv)
     
        
    rr = Sqr(xx * xx + yy * yy)

    vm = vv

    rm = rr
    
    x = rm * (Cos(nm * kk) * Cos((vm + wm) * kk) - sin(nm * kk) * sin((vm + wm) * kk) * Cos(im * kk))
    Y = rm * (sin(nm * kk) * Cos((vm + wm) * kk) + Cos(nm * kk) * sin((vm + wm) * kk) * Cos(im * kk))
    Z = rm * (sin(((vm + wm) * kk)) * sin(im * kk))

           

    lon = Atn(Y / x) * 180 / 3.14159265358979
    
    If x < 0 Then
    lon = 180 + lon
     End If
    lon = range360(lon)
    
        
    
    lat = Atn(Z / Sqr(x * x + Y * Y)) * 180 / 3.14159265358979
       
      
    ws = range360(282.9404 + 0.0000470935 * d)
    Ms = range360(356.047 + 0.9856002585 * d)
    '   perturbations
    '   first calculate arguments below,
    'Ms, Mm             Mean Anomaly of the Sun and the Moon
    'Nm                 Longitude of the Moon's node
    'ws, wm             Argument of perihelion for the Sun and the Moon
    ls = Ms + ws       'Mean Longitude of the Sun  (Ns=0)
    lm = Mm + wm + nm  'Mean longitude of the Moon
    dm = lm - ls        'Mean elongation of the Moon
    F = lm - nm        'Argument of latitude for the Moon
    
       
            rm = rm - 0.58 * Cos((Mm - 2 * dm) * kk)
            rm = rm - 0.46 * Cos((2 * dm) * kk)


          moonr = rm
     
            dlat = -0.173 * sin(kk * (F - 2 * dm))
            dlat = dlat - 0.055 * sin(kk * (Mm - F - 2 * dm))
            dlat = dlat - 0.046 * sin(kk * (Mm + F - 2 * dm))
            dlat = dlat + 0.033 * sin(kk * (F + 2 * dm))
            dlat = dlat + 0.017 * sin(kk * (2 * Mm + F))

          moonlat = lat + dlat
       

            dlon = -1.274 * sin(kk * (Mm - 2 * dm))        '(the Evection)
            dlon = dlon + 0.658 * sin(kk * (2 * dm))       '(the Variation)
            dlon = dlon - 0.186 * sin(Ms * kk)           '(the Yearly Equation)
            dlon = dlon - 0.059 * sin(kk * (2 * Mm - 2 * dm))
            dlon = dlon - 0.057 * sin(kk * (Mm - 2 * dm + Ms))
            dlon = dlon + 0.053 * sin(kk * (Mm + 2 * dm))
            dlon = dlon + 0.046 * sin(kk * (2 * dm - Ms))
            dlon = dlon + 0.041 * sin(kk * (Mm - Ms))
            dlon = dlon - 0.035 * sin(kk * dm)           '(the Parallactic Equation)
            dlon = dlon - 0.031 * sin(kk * (Mm + Ms))
            dlon = dlon - 0.015 * sin(kk * (2 * F - 2 * dm))
            dlon = dlon + 0.011 * sin(kk * (Mm - 4 * dm))

            moonlon = lon + dlon


    xmoon = moonr * Cos(moonlon * kk) * Cos(moonlat * kk)
    ymoon = moonr * sin(moonlon * kk) * Cos(moonlat * kk)
    zmoon = moonr * sin(moonlat * kk)

    xemoon = xmoon
    yemoon = ymoon * 0.917482061 - zmoon * 0.397777159
    zemoon = ymoon * 0.397777159 + zmoon * 0.917482061

    decmoon = Atn(zemoon / Sqr(xemoon * xemoon + yemoon * yemoon)) * 180 / 3.14159265358979


ramoon = Atn(yemoon / xemoon) * 180 / 3.14159265358979

If xemoon < 0 Then
    ramoon = 180 + ramoon
     End If
   ramoon = range360(ramoon)

  
    
    dec = decmoon

    RA = ramoon
    
     
    
    
  
  dz = (jdx - 2451545) / 36525
  
  gst = range360(280.46061837 + 360.98564736629 * (jdx - 2451545) + 0.000387933 * dz * dz - dz * dz * dz / 38710000)
  
   
      
    If Lnge < 0 Then
Lnge = 360 + Lnge
End If

Stdw = range360(gst - (360 - Lnge) - RA)
   
    
aaa = sin(Stdw * 3.14159265358979 / 180)
bbb = Cos(Stdw * 3.14159265358979 / 180) * sin(Breite * 3.14159265358979 / 180) - Tan(dec * 3.14159265358979 / 180) * Cos(Breite * 3.14159265358979 / 180)

cccc = Application.Atan2(bbb, aaa) * 180 / 3.14159265358979 + 180

If ccc < 0 Then ccc = ccc + 360 Else

AzimutN = cccc

dgmond = AzimutN
 
    
 If Round(dgmond, 0) = 180 Then
nn = 1
aaaaaa = aaaaaa

GoTo 100

End If

DoEvents

Next
    
100:

nn = nn

    
 dgmond = aaaaaa * 24 / 24
 If nn = 0 Then
 dgmond = "-"
 End If
 
 
  dgmond = dgmond
  
  
  
  
  
  If nn = 1 Then
  jddg = aaaaaa + jdnull + 1 / (24 * 60)
  jd = jddg
  End If
  
  
  
  
  
  
  
 kk = 3.14159265358979 / 180
d = jd - 2451543.5
jdx = jd


  
    nm = range360(125.1228 - 0.0529538083 * d)
    im = 5.1454
    wm = range360(318.0634 + 0.1643573223 * d)
    am = 60.2666  '(Earth radii)
    ecm = 0.0549
    Mm = range360(115.3654 + 13.0649929509 * d) 'M
    
    Enull = Mm + (180 / 3.14159265358979) * ecm * sin(Mm * 3.14159265358979 / 180) * (1 + ecm * Cos(Mm * 3.14159265358979 / 180))
    
    Eeins = Enull - (Enull - (180 / 3.14159265358979) * ecm * sin(Enull * 3.14159265358979 / 180) - Mm) / (1 - ecm * Cos(Enull * 3.14159265358979 / 180))
    
    Ezwei = Eeins - (Eeins - (180 / 3.14159265358979) * ecm * sin(Eeins * 3.14159265358979 / 180) - Mm) / (1 - ecm * Cos(Eeins * 3.14159265358979 / 180))
    
    xx = am * (Cos(Ezwei * 3.14159265358979 / 180) - ecm)
    yy = am * Sqr(1 - ecm * ecm) * sin(Ezwei * 3.14159265358979 / 180)
     
    
    
    xv = xx
    yv = yy
    
     vv = Atn(yy / xx) * 180 / 3.14159265358979
     If xx < 0 Then
     vv = 180 + vv
     End If
     vv = range360(vv)
     
        
    rr = Sqr(xx * xx + yy * yy)

    vm = vv

    rm = rr
    
    x = rm * (Cos(nm * kk) * Cos((vm + wm) * kk) - sin(nm * kk) * sin((vm + wm) * kk) * Cos(im * kk))
    Y = rm * (sin(nm * kk) * Cos((vm + wm) * kk) + Cos(nm * kk) * sin((vm + wm) * kk) * Cos(im * kk))
    Z = rm * (sin(((vm + wm) * kk)) * sin(im * kk))

           

    lon = Atn(Y / x) * 180 / 3.14159265358979
    
    If x < 0 Then
    lon = 180 + lon
     End If
    lon = range360(lon)
    
        
    
    lat = Atn(Z / Sqr(x * x + Y * Y)) * 180 / 3.14159265358979
       
      
    ws = range360(282.9404 + 0.0000470935 * d)
    Ms = range360(356.047 + 0.9856002585 * d)
    '   perturbations
    '   first calculate arguments below,
    'Ms, Mm             Mean Anomaly of the Sun and the Moon
    'Nm                 Longitude of the Moon's node
    'ws, wm             Argument of perihelion for the Sun and the Moon
    ls = Ms + ws       'Mean Longitude of the Sun  (Ns=0)
    lm = Mm + wm + nm  'Mean longitude of the Moon
    dm = lm - ls        'Mean elongation of the Moon
    F = lm - nm        'Argument of latitude for the Moon
    
       
            rm = rm - 0.58 * Cos((Mm - 2 * dm) * kk)
            rm = rm - 0.46 * Cos((2 * dm) * kk)


          moonr = rm
     
            dlat = -0.173 * sin(kk * (F - 2 * dm))
            dlat = dlat - 0.055 * sin(kk * (Mm - F - 2 * dm))
            dlat = dlat - 0.046 * sin(kk * (Mm + F - 2 * dm))
            dlat = dlat + 0.033 * sin(kk * (F + 2 * dm))
            dlat = dlat + 0.017 * sin(kk * (2 * Mm + F))

          moonlat = lat + dlat
       

            dlon = -1.274 * sin(kk * (Mm - 2 * dm))        '(the Evection)
            dlon = dlon + 0.658 * sin(kk * (2 * dm))       '(the Variation)
            dlon = dlon - 0.186 * sin(Ms * kk)           '(the Yearly Equation)
            dlon = dlon - 0.059 * sin(kk * (2 * Mm - 2 * dm))
            dlon = dlon - 0.057 * sin(kk * (Mm - 2 * dm + Ms))
            dlon = dlon + 0.053 * sin(kk * (Mm + 2 * dm))
            dlon = dlon + 0.046 * sin(kk * (2 * dm - Ms))
            dlon = dlon + 0.041 * sin(kk * (Mm - Ms))
            dlon = dlon - 0.035 * sin(kk * dm)           '(the Parallactic Equation)
            dlon = dlon - 0.031 * sin(kk * (Mm + Ms))
            dlon = dlon - 0.015 * sin(kk * (2 * F - 2 * dm))
            dlon = dlon + 0.011 * sin(kk * (Mm - 4 * dm))

            moonlon = lon + dlon


    xmoon = moonr * Cos(moonlon * kk) * Cos(moonlat * kk)
    ymoon = moonr * sin(moonlon * kk) * Cos(moonlat * kk)
    zmoon = moonr * sin(moonlat * kk)

    xemoon = xmoon
    yemoon = ymoon * 0.917482061 - zmoon * 0.397777159
    zemoon = ymoon * 0.397777159 + zmoon * 0.917482061

    decmoon = Atn(zemoon / Sqr(xemoon * xemoon + yemoon * yemoon)) * 180 / 3.14159265358979


ramoon = Atn(yemoon / xemoon) * 180 / 3.14159265358979

If xemoon < 0 Then
    ramoon = 180 + ramoon
     End If
   ramoon = range360(ramoon)

  
    
    dec = decmoon

    RA = ramoon
    
     
    
    
  
  dz = (jdx - 2451545) / 36525
  
  gst = range360(280.46061837 + 360.98564736629 * (jdx - 2451545) + 0.000387933 * dz * dz - dz * dz * dz / 38710000)
  
   
      
    If Lnge < 0 Then
Lnge = 360 + Lnge
End If

Stdw = range360(gst - (360 - Lnge) - RA)
   
    
aaa = sin(Stdw * 3.14159265358979 / 180)
bbb = Cos(Stdw * 3.14159265358979 / 180) * sin(Breite * 3.14159265358979 / 180) - Tan(dec * 3.14159265358979 / 180) * Cos(Breite * 3.14159265358979 / 180)

cccc = Application.Atan2(bbb, aaa) * 180 / 3.14159265358979 + 180

If ccc < 0 Then ccc = ccc + 360 Else

AzimutN2 = cccc
  
  
  
azidifmin = AzimutN2 - AzimutN
graddif = 1 / azidifmin

azidif = 180 - AzimutN
  
zeitadi = graddif * azidif
  
 zeitadi = zeitadi / (24 * 60)
 
 
  dgmond = dgmond + zeitadi
  

    
End Function

