Convidado 20/7/2011, 18:52
Eis o pequeno código para distancia lunar...
Function MoonDISTANCE_Kms(Year As Double, Month As Double, Day As Double, Hour As Double, _
Min As Double, Sec As Double, TIME_ZONE As Double, Daylight_Time As Double, Optional Greg) As Double
YY = Year - Int((12 - Month) / 10)
If (Year < 1) Then
YY = Year - Int((12 - Month) / 10) + 1
End If
MM = Month + 9
If (MM >= 12) Then
MM = MM - 12
End If
K1 = Int(365.25 * (YY + 4712))
K2 = Int(30.6 * MM + 0.5)
K3 = Int(Int((YY / 100) + 49) * 0.75) - 38
J1 = K1 + K2 + Day + 59 ' JD for dates in Julian calendar
If (J1 > 2299160#) Then
J1 = J1 - K3: ' For Gregorian calendar
End If
l1 = J1 + (((Hour + (Min / 60) + (Sec / 3600)) / 24) - 0.5) - ((TIME_ZONE + Daylight_Time) / 24) - 2451545
'Preciso saber nesta parte em vermelho o valor de TIMEZONE e DAYLIGHT é apenas hora ou decimal
' This is the number of Julian Days from the year 2000.
E13 = l1 / 36525
B26 = 1 - 0.002516 * E13 - 0.0000074 * E13 ^ 2
B27 = B26 ^ 2
C18 = Range360(297.8502042 + 445267.1115168 * E13 - 0.00163 * E13 ^ 2 + E13 ^ 3 / 545868 - E13 ^ 4 / 113065000) * PI / 180
C19 = Range360(357.5291092 + 35999.0502909 * E13 - 0.0001536 * E13 ^ 2 + E13 ^ 3 / 24490000) * PI / 180
C20 = Range360(134.9634114 + 477198.8676313 * E13 + 0.008997 * E13 ^ 2 + E13 ^ 3 / 69699 - E13 ^ 4 / 14712000) * PI / 180
C21 = Range360(93.2720993 + 483202.0175273 * E13 - 0.0034029 * E13 ^ 2 + E13 ^ 3 / 3526000 - E13 ^ 4 / 863310000) * PI / 180
a = -20905355 * Cos(C20)
b = -3699111 * Cos(2 * C18 - C20)
C = -2955968 * Cos(2 * C18)
d = -569925 * Cos(2 * C20)
e = 48888 * B26 * Cos(C19)
F = -3149 * Cos(2 * C21)
G = 246158 * Cos(2 * C18 - 2 * C20)
h = -152138 * B26 * Cos(2 * C18 - C19 - C20)
I = -170733 * Cos(2 * C18 + C20)
j = -204586 * B26 * Cos(2 * C18 - C19)
k = -129620 * B26 * Cos(C19 - C20)
L = 108743 * Cos(C18)
m = 104755 * B26 * Cos(C19 + C20)
n = 10321 * Cos(2 * C18 - 2 * C21)
o = 79661 * Cos(C20 - 2 * C21)
p = -34782 * Cos(4 * C18 - 1 * C20)
q = -23210 * Cos(3 * C20)
r = -21636 * Cos(4 * C18 - 2 * C20)
S = 24208 * B26 * Cos(2 * C18 + C19 - 1 * C20)
T = 30824 * B26 * Cos(2 * C18 + C19)
u = -8379 * Cos(C18 - C20)
V = -16675 * B26 * Cos(C18 + C19)
w = -12831 * B26 * Cos(2 * C18 - C19 + C20)
X = -10445 * Cos(2 * C18 + 2 * C20)
Y = -11650 * Cos(4 * C18)
Z = 14403 * Cos(2 * C18 - 3 * C20)
aa = -7003 * B26 * Cos(C19 - 2 * C20)
bb = 10056 * B26 * Cos(2 * C18 - C19 - 2 * C20)
CC = 6322 * Cos(C18 + C20)
dd = -9884 * B27 * Cos(2 * C18 - 2 * C19)
ee = 5751 * B26 * Cos(C19 + 2 * C20)
ff = -4950 * B27 * Cos(2 * C18 - 2 * C19 - C20)
GG = 4130 * Cos(2 * C18 + C20 - 2 * C21)
HH = -3958 * B26 * Cos(4 * C18 - C19 - C20)
ii = 3258 * Cos(3 * C18 - C20)
jj = 2616 * B26 * Cos(2 * C18 + C19 + C20)
kk = -1897 * B26 * Cos(4 * C18 - C19 - 2 * C20)
ll = -2117 * B27 * Cos(2 * C19 - C20)
MM = 2354 * B27 * Cos(2 * C18 + 2 * C19 - C20)
nn = -1423 * Cos(4 * C18 + C20)
oo = -1117 * Cos(4 * C20)
pp = -1571 * B26 * Cos(4 * C18 - C19)
qq = -1739 * Cos(C18 - 2 * C20)
rr = -4421 * Cos(2 * C20 - 2 * C21)
SS = 1165 * B27 * Cos(2 * C19 + C20 + K63)
tt = 8752 * Cos(2 * C18 - C20 - 2 * C21)
uu = a + b + C + d + e + F + G + h + I + j + k + L + m + n + o + p + q + r + S + T + u + V + w + X + Y + Z + aa + bb + CC + dd + ee + ff + GG + HH + ii + jj + kk + ll + MM + nn + oo + pp + qq + rr + SS + tt
VV = 385000.56 + uu / 1000
MoonDISTANCE_Kms = VV 'para MILHAS, divida por 1.6093440058
'Joga no form as distâncias para lua em KM e Milhas