forked from gopa810/gcal-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GCAyanamsha.cpp
147 lines (122 loc) · 3.29 KB
/
GCAyanamsha.cpp
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
#include "stdafx.h"
#include "GCAyanamsha.h"
int GCAyanamsha::ayamashaType = 1;
GCAyanamsha::GCAyanamsha(void)
{
}
GCAyanamsha::~GCAyanamsha(void)
{
}
//==================================================================
//
// precession of the equinoxes http://en.wikipedia.org/wiki/Precession_%28astronomy%29
//
//==================================================================
double GCAyanamsha::GetAyanamsa(double jdate)
{
double t, d;
double a1;
// progress of ayanamsa from 1950 to 2000
//1.3971948971667
t = (jdate - 2451545.0) / 36525.0;
d = (5028.796195 - 1.1054348*t)*t / 3600.0;
switch(GCAyanamsha::ayamashaType)
{
case 0: // Fagan-Bradley
a1 = 24.8361111111 -0.095268987143399+ d;
//-69.943382314 + jdate * 3.8263328316687189e-5;
break;
case 1: // Lahiri
a1 = 23.85305555555 + d;
//a1 = GetLahiriAyanamsa(jdate);
// 23-51-14 in 2000
//TRACE("Ayan lahiri = %f\n", a1 - GetLahiriAyanamsa(jdate));
break;
case 2: // Krishnamurti
a1 = 23.8561111111 -0.095268987143399+ d;
break;
case 3: // Raman
a1 = 22.5066666666 -0.095268987143399+ d;
break;
default:
break;
}
return a1;
}
const char * GCAyanamsha::GetAyanamsaName(int nType)
{
const char * pNames[] = {
"Fagan/Bradley",
"Lahiri",
"Krishnamurti",
"Raman"
};
if (nType > 3)
return "";
return pNames[nType];
}
//==================================================================
//
//==================================================================
int GCAyanamsha::GetAyanamsaType(void)
{
return GCAyanamsha::ayamashaType;
}
//==================================================================
//
//==================================================================
int GCAyanamsha::SetAyanamsaType(int i)
{
int prev = GCAyanamsha::ayamashaType;
GCAyanamsha::ayamashaType = i;
return prev;
}
/*********************************************************************/
/* */
/* Value of Ayanamsha for given Julian day */
/* */
/*********************************************************************/
/*
27.8.1900 22-27-54 2415259.000000 22,475
23.7.1950 23-09-53 2433486.000000 23,16472
3.9.2000 23-52-13 2451791.000000 23,870277778
28.8.2010 24-00-04 2455437.000000 24,001111111
21.6.2050 24-33-29 2469979.000000 24,558055556
14.6.2100 25-15-29 2488234.000000 25,258055556*/
double GCAyanamsha::GetLahiriAyanamsa(double d)
{
double h[] = { 2415259.000000,22.475,
2433486.000000,23.16472,
2451791.000000,23.870277778,
2455437.000000,24.001111111,
2469979.000000,24.558055556,
2488234.000000,25.258055556 };
if (d > h[10])
{
return (d - h[10]) * ((h[11] - h[9]) / (h[10] - h[8])) + h[11];
}
else if (d > h[8])
{
return (d - h[8]) * ((h[11] - h[9]) / (h[10] - h[8])) + h[9];
}
else if (d > h[6])
{
return (d - h[6]) * ((h[9] - h[7]) / (h[8] - h[6])) + h[7];
}
else if (d > h[4])
{
return (d - h[4]) * ((h[7] - h[5]) / (h[6] - h[4])) + h[5];
}
else if (d > h[2])
{
return (d - h[2]) * ((h[5] - h[3]) / (h[4] - h[2])) + h[3];
}
else if (d > h[0])
{
return (d - h[0]) * ((h[3] - h[1]) / (h[2] - h[0])) + h[1];
}
else
{
return (d - h[0]) * ((h[3] - h[1]) / (h[2] - h[0])) + h[1];
}
}