-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathswhraman.c
246 lines (230 loc) · 7.33 KB
/
swhraman.c
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
Swephelp
Copyright 2007-2020 Stanislas Marquis <[email protected]>
Swephelp is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
Swephelp is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Swephelp. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "swhdef.h"
#include "swhraman.h"
int swh_raman_houses(double asc, double mc, double *ret, int sandhi)
{
double arc;
if (sandhi == 0) /* we want bhavamadhya */
{
ret[0] = swe_degnorm(asc);
ret[9] = swe_degnorm(mc);
}
else /* we want arambhasandhi */
{
arc = fabs(swe_difdeg2n(asc, mc)) / 6.0;
ret[0] = swe_degnorm(asc - arc);
ret[9] = swe_degnorm(mc - arc);
}
ret[6] = swe_degnorm(ret[0] + 180);
ret[3] = swe_degnorm(ret[9] + 180);
arc = fabs(swe_difdeg2n(ret[0], ret[9])) / 3.0;
ret[11] = swe_degnorm(ret[0] - arc);
ret[10] = swe_degnorm(ret[9] + arc);
ret[4] = swe_degnorm(ret[10] + 180);
ret[5] = swe_degnorm(ret[11] + 180);
arc = fabs(swe_difdeg2n(ret[0], ret[3])) / 3.0;
ret[1] = swe_degnorm(ret[0] + arc);
ret[2] = swe_degnorm(ret[3] - arc);
ret[7] = swe_degnorm(ret[1] + 180);
ret[8] = swe_degnorm(ret[2] + 180);
return 0;
}
int swh_lord(int sign)
{
switch (sign)
{
case SWH_ARIES:
case SWH_SCORPIO: return SE_MARS;
case SWH_TAURUS:
case SWH_LIBRA: return SE_VENUS;
case SWH_GEMINI:
case SWH_VIRGO: return SE_MERCURY;
case SWH_CANCER: return SE_MOON;
case SWH_LEO: return SE_SUN;
case SWH_SAGITTARIUS:
case SWH_PISCES: return SE_JUPITER;
case SWH_CAPRICORN:
case SWH_AQUARIUS: return SE_SATURN;
default: return -1;
}
}
int swh_long2nakshatra(double longitude, int *ret)
{
longitude = swe_degnorm(longitude);
ret[0] = (int) (longitude / (40/3.0));
ret[1] = (int) ((longitude - (ret[0] * (40/3.0))) / (10/3.0));
return 0;
}
int swh_get_nakshatra_name(int nakshatra, char *str)
{
switch (nakshatra)
{
case SWH_ASWINI: strcpy(str, "Aswini"); return 0;
case SWH_BHARANI: strcpy(str, "Bharani"); return 0;
case SWH_KRITHIKA: strcpy(str, "Krithika"); return 0;
case SWH_ROHINI: strcpy(str, "Rohini"); return 0;
case SWH_MRIGASIRA: strcpy(str, "Mrigasira"); return 0;
case SWH_ARIDRA: strcpy(str, "Aridra"); return 0;
case SWH_PUNARVASU: strcpy(str, "Punarvasu"); return 0;
case SWH_PUSHYAMI: strcpy(str, "Pushyami"); return 0;
case SWH_ASLESHA: strcpy(str, "Aslesha"); return 0;
case SWH_MAKHA: strcpy(str, "Makha"); return 0;
case SWH_PUBBA: strcpy(str, "Pubba"); return 0;
case SWH_UTTARA: strcpy(str, "Uttara"); return 0;
case SWH_HASTA: strcpy(str, "Hasta"); return 0;
case SWH_CHITTA: strcpy(str, "Chitta"); return 0;
case SWH_SWATHI: strcpy(str, "Swathi"); return 0;
case SWH_VISHAKA: strcpy(str, "Vishaka"); return 0;
case SWH_ANURADHA: strcpy(str, "Anuradha"); return 0;
case SWH_JYESTA: strcpy(str, "Jyesta"); return 0;
case SWH_MOOLA: strcpy(str, "Moola"); return 0;
case SWH_POORVASHADA: strcpy(str, "Poorvashada"); return 0;
case SWH_UTTARASHADA: strcpy(str, "Uttarashada"); return 0;
case SWH_SRAVANA: strcpy(str, "Sravana"); return 0;
case SWH_DHANISHTA: strcpy(str, "Dhanishta"); return 0;
case SWH_SATABISHA: strcpy(str, "Satabhisha"); return 0;
case SWH_POORVABHADRA: strcpy(str, "Poorvabhadra"); return 0;
case SWH_UTTARABHADRA: strcpy(str, "Uttarabhadra"); return 0;
case SWH_REVATHI: strcpy(str, "Revathi"); return 0;
default: return -1;
}
}
int swh_rasi_dif(int r1, int r2)
{
r1 = swh_rasinorm(r1);
r2 = swh_rasinorm(r2);
if (r1 == r2) return 0;
else if (r1 < r2) return 12 - (r2 - r1);
else return r1 - r2;
}
int swh_rasi_dif2(int r1, int r2)
{
const int i = swh_rasi_dif(r1, r2);
return (i > 6) ? (-6 + (i - 6)) : (i);
}
int swh_naisargika_relation(int gr1, int gr2, int *ret)
{
switch (gr1)
{
case SE_SUN:
switch (gr2)
{
case SE_MOON: case SE_MARS: case SE_JUPITER: goto mitra;
case SE_MERCURY: goto sama;
case SE_VENUS: case SE_SATURN: goto satru;
}
case SE_MOON:
switch (gr2)
{
case SE_SUN: case SE_MERCURY: goto mitra;
case SE_MARS: case SE_JUPITER: case SE_VENUS: case SE_SATURN: goto sama;
}
case SE_MERCURY:
switch (gr2)
{
case SE_SUN: case SE_VENUS: goto mitra;
case SE_MARS: case SE_JUPITER: case SE_SATURN: goto sama;
case SE_MOON: goto satru;
}
case SE_VENUS:
switch (gr2)
{
case SE_MERCURY: case SE_SATURN: goto mitra;
case SE_MARS: case SE_JUPITER: goto sama;
case SE_SUN: case SE_MOON: goto satru;
}
case SE_MARS:
switch (gr2)
{
case SE_SUN: case SE_MOON: case SE_JUPITER: goto mitra;
case SE_VENUS: case SE_SATURN: goto sama;
case SE_MERCURY: goto satru;
}
case SE_JUPITER:
switch (gr2)
{
case SE_SUN: case SE_MOON: case SE_MARS: goto mitra;
case SE_SATURN: goto sama;
case SE_MERCURY: case SE_VENUS: goto satru;
}
case SE_SATURN:
switch (gr2)
{
case SE_MERCURY: case SE_VENUS: goto mitra;
case SE_JUPITER: goto sama;
case SE_SUN: case SE_MOON: case SE_MARS: goto satru;
}
}
return -1;
mitra: *ret = 1; return 0;
sama: *ret = 0; return 0;
satru: *ret = -1; return 0;
}
int swh_residential_strength(double graha, const double *bm, double *ret)
{
int i;
double s, arc1, arc2;
static const int idx[] = {0,1,2,3,4,5,6,7,8,9,10,11,0};
for (i = 0; i < 12; ++i)
{
if (graha == bm[idx[i]] || graha == bm[idx[i+1]])
{
*ret = 0; return 0;
}
arc1 = swe_difdeg2n(bm[idx[i]], graha);
arc2 = swe_difdeg2n(bm[idx[i+1]], graha);
if ((arc1 >= 0 ? 1 : 0) !=
(arc2 >= 0 ? 1 : 0)
&& fabs(arc1) + fabs(arc2) < 180)
{
s = swe_deg_midp(bm[idx[i]], bm[idx[i+1]]);
if (graha == s)
{
*ret = 1.0; return 0;
}
arc1 = fabs(arc1);
arc2 = fabs(arc2);
if (arc1 < arc2)
{
*ret = (arc1 / fabs(swe_difdeg2n(s, bm[idx[i]])));
}
else
{
*ret = (arc2 / fabs(swe_difdeg2n(s, bm[idx[i+1]])));
}
return 0;
}
}
return -1;
}
double swh_ochchabala(int graha, double sputha)
{
int x;
switch (graha)
{
case SE_SUN: x = 190; break;
case SE_MOON: x = 213; break;
case SE_MERCURY: x = 345; break;
case SE_VENUS: x = 177; break;
case SE_MARS: x = 118; break;
case SE_JUPITER: x = 275; break;
case SE_SATURN: x = 20; break;
default: return -1;
}
return fabs(swe_difdeg2n(sputha, x)) / 3.0;
}
/* vi: set fenc=utf-8 ff=unix et sw=4 ts=4 : */