根据上面找的链接中的C++代码,找到了核心程序,修改如下,能够计算出实时的天顶的RA值是多少,但是有误差 一分多钟,所以加了常数(没有精确的加,所以最后结果还有是有些误差)
PR = 3.14159265358979 / 180
Dim PI As Double
PI = 3.14159265358979
M(1) = 0: M(2) = 31: M(3) = 59: M(4) = 90
M(5) = 120: M(6) = 1512: M(7) = 181: M(8) = 212
M(9) = 243: M(10) = 273: M(11) = 304: M(12) = 334
Y(1998) = -731.5: Y(1999) = -366.5: Y(2000) = -1.5: Y(2001) = 364.5
Y(2002) = 729.5: Y(2003) = 1094.5: Y(2004) = 1459.5: Y(2005) = 1825.5
Y(2006) = 2190.5: Y(2007) = 2555.5: Y(2008) = 2920.5: Y(2009) = 3286.5
Y(2010) = 3651.5: Y(2011) = 4016.5: Y(2012) = 4381.5: Y(2013) = 4747.5
Y(2014) = 5112.5: Y(2015) = 5477.5: Y(2016) = 5842.5: Y(2017) = 6208.5
Y(2018) = 6573.5: Y(2019) = 6938.5: Y(2020) = 7303.5: Y(2021) = 7669.5
J2000 = (Hour(Time) + Minute(Time) / 60 + Second(Time) / 3600) / 24 + M(Month(Date)) + Day(Date) + Y(Year(Date))
'Debug.Print "J2000"; J2000
'Debug.Print "LON"; LON
LST = 100.46 + 0.985647 * J2000 + LON + 15 * (Hour(Time) + Minute(Time) / 60 + Second(Time) / 3600)
' Debug.Print "LST"; LST
Dim temp, sin_dec, cos_lat As Double
cos_lat = Cos(LAT)
Dim alt, az, dec As Double
alt = 0
az = 0
sin_dec = Sin(LAT * PR) * Sin(alt * PR) + cos_lat * Cos(alt * PR) * Cos(az * PR)
dec = Atn(sin_dec / Sqr(-sin_dec * sin_dec + 1))
Debug.Print " dec"; dec / PR
temp = cos_lat * Cos(dec * PR)
temp = (Sin(alt * PR) - Sin(LAT * PR) * sin_dec) / temp
' temp = acose(-temp) 'cos(-temp)
temp = Atn(-Cos(-temp) / Sqr(-Cos(-temp) * Cos(-temp) + 1)) + 2 * Atn(1)
If (Sin(az) >= 0) Then
HA = PI - temp
Else
HA = PI + temp
End If
Debug.Print "HA"; HA * 360 / PI
HA = HA * 360 / PI
Do Until LST <= 360
LST = LST - 360
Loop
Do Until HA >= 0
HA = HA + 360
Loop
ra_tian_ind = (LST - HA)
If ra_tian_ind < 0 Then
ra_tian_ind = 360 + ra_tian_ind
End If
ra_tian_ind = ra_tian_ind - 18 / 60 '计算值不对,有误差,加个常数调整
'天顶的 RA值 |