-
Notifications
You must be signed in to change notification settings - Fork 67
/
charts2.cpp
1799 lines (1651 loc) · 59.3 KB
/
charts2.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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Astrolog (Version 7.70) File: charts2.cpp
**
** IMPORTANT NOTICE: Astrolog and all chart display routines and anything
** not enumerated below used in this program are Copyright (C) 1991-2024 by
** Walter D. Pullen ([email protected], http://www.astrolog.org/astrolog.htm).
** Permission is granted to freely use, modify, and distribute these
** routines provided these credits and notices remain unmodified with any
** altered or distributed versions of the program.
**
** The main ephemeris databases and calculation routines are from the
** library SWISS EPHEMERIS and are programmed and copyright 1997-2008 by
** Astrodienst AG. Use of that source code is subject to license for Swiss
** Ephemeris Free Edition at https://www.astro.com/swisseph/swephinfo_e.htm.
** This copyright notice must not be changed or removed by any user of this
** program.
**
** Additional ephemeris databases and formulas are from the calculation
** routines in the program PLACALC and are programmed and Copyright (C)
** 1989,1991,1993 by Astrodienst AG and Alois Treindl ([email protected]). The
** use of that source code is subject to regulations made by Astrodienst
** Zurich, and the code is not in the public domain. This copyright notice
** must not be changed or removed by any user of this program.
**
** The original planetary calculation routines used in this program have
** been copyrighted and the initial core of this program was mostly a
** conversion to C of the routines created by James Neely as listed in
** 'Manual of Computer Programming for Astrologers', by Michael Erlewine,
** available from Matrix Software.
**
** Atlas composed using data from https://www.geonames.org/ licensed under a
** Creative Commons Attribution 4.0 License. Time zone changes composed using
** public domain TZ database: https://data.iana.org/time-zones/tz-link.html
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby ([email protected]).
**
** More formally: This program 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. This program is
** distributed in the hope that it will be useful and inspiring, 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, a copy of which is in the
** LICENSE.HTM file included with Astrolog, and at http://www.gnu.org
**
** Initial programming 8/28-30/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 4/22/2024.
*/
#include "astrolog.h"
/*
******************************************************************************
** Dual Chart Display Routines.
******************************************************************************
*/
// Print a listing of planets for two (or more) charts, as specified by the
// -v -r0 switch combination, along with the maximum delta between planets.
void ChartListingRelation(void)
{
char sz[cchSzDef], szFormat[cchSzDef];
int cChart, i, j, k, l, n;
real r, rT;
cChart = 2 - (FBetween(us.nRel, rcHexaWheel, rcTriWheel) ? us.nRel+1 : 0);
// Print header rows.
AnsiColor(kWhiteA);
n = us.fSeconds ? 23 : 16;
sprintf(szFormat, " %%-%d.%ds", n, n);
for (n = 0, i = 1; i <= cChart; i++)
n += FSzSet(rgpci[i]->nam);
if (n > 0) {
PrintTab(' ', 5);
for (i = 1; i <= cChart; i++) {
AnsiColor(kMainA[FOdd(i) ? 1 : 3]);
sprintf(sz, szFormat, rgpci[i]->nam); PrintSz(sz);
}
PrintL();
}
PrintTab(' ', 6);
for (i = 1; i <= cChart; i++) {
AnsiColor(kMainA[FOdd(i) ? 1 : 3]);
if (!FNoTimeOrSpace(*rgpci[i])) {
sprintf(sz, "%s %s", SzDate(rgpci[i]->mon, rgpci[i]->day,
rgpci[i]->yea, us.fSeconds-1), SzTim(rgpci[i]->tim));
PrintSz(sz);
PrintTab(' ', (us.fSeconds ? 24 : 17) - CchSz(sz));
} else
PrintSz(us.fSeconds ? "(No time or space) " : "(No time/space) ");
}
PrintL();
for (n = 0, i = 1; i <= cChart; i++)
n += FSzSet(rgpci[i]->loc);
if (n > 0) {
PrintTab(' ', 5);
for (i = 1; i <= cChart; i++) {
AnsiColor(kMainA[FOdd(i) ? 1 : 3]);
sprintf(sz, szFormat, rgpci[i]->loc); PrintSz(sz);
}
PrintL();
}
PrintTab(' ', 5);
for (i = 1; i <= cChart; i++) {
AnsiColor(kMainA[FOdd(i) ? 1 : 3]);
sprintf(sz, szFormat, SzLocation(rgpci[i]->lon, rgpci[i]->lat));
PrintSz(sz);
}
AnsiColor(kDkGrayA);
PrintSz("\nBody");
for (i = 1; i <= cChart; i++) {
AnsiColor(kMainA[FOdd(i) ? 1 : 3]);
PrintSz(" Location");
PrintTab(' ', us.fSeconds ? 5 : 1);
if (us.fSeconds)
PrintSz(!us.fEquator2 ? " Latitude" : " Declin. ");
else
PrintSz(!us.fEquator2 ? "Latit." : "Decl. ");
}
AnsiColor(kMainA[FOdd(i) ? 3 : 1]);
PrintTab(' ', 3 + us.fSeconds);
PrintSz("Delta\n");
// Print object positions.
for (l = 0; l <= is.nObj; l++) {
i = rgobjList[l];
if (FIgnore(i))
continue;
AnsiColor(kObjA[i]);
sprintf(sz, "%-4.4s:", szObjDisp[i]); PrintSz(sz);
for (j = 1; j <= cChart; j++) {
PrintCh(' ');
PrintZodiac(rgpcp[j]->obj[i]);
sprintf(sz, "%c ", rgpcp[j]->dir[i] >= 0.0 ? ' ' : chRet); PrintSz(sz);
PrintAltitude(rgpcp[j]->alt[i]);
}
// Compute maximum offset between any two instances of this planet.
r = 0.0;
for (j = 1; j <= cChart; j++)
for (k = 1; k < j; k++) {
if (!us.fAspect3D)
rT = MinDistance(rgpcp[j]->obj[i], rgpcp[k]->obj[i]);
else
rT = SphDistance(rgpcp[j]->obj[i], rgpcp[j]->alt[i],
rgpcp[k]->obj[i], rgpcp[k]->alt[i]);
r = Max(r, rT);
}
AnsiColor(kDkGrayA);
PrintCh(' ');
PrintSz(SzDegree(r));
PrintL();
}
}
// Print out an aspect (or midpoint if -gm switch in effect) grid of a
// relationship chart. This is similar to the ChartGrid() routine, however
// here both axes are labeled with the planets for the two charts in question,
// instead of just a diagonal down the center for only one chart.
void ChartGridRelation(void)
{
int i0, j0, i, j, k, temp;
#ifdef INTERPRET
if (us.fInterpret && !us.fGridMidpoint) {
InterpretGridRelation();
return;
}
#endif
for (k = 2; k <= 4 + us.fSeconds; k++) {
PrintSz(k <= 2 ? " 2>" : (k == 3 ? "1 " : (k == 4 ? "V " : " ")));
for (i0 = 0; i0 <= is.nObj; i0++) {
i = rgobjList[i0];
if (ignore[i])
continue;
PrintCh2(chV);
PrintGridCell(-3, i, 0, k);
AnsiColor(kDefault);
}
PrintL();
}
for (j0 = 0; j0 <= is.nObj; j0++) {
j = rgobjList[j0];
if (ignore[j])
continue;
for (k = 1; k <= 4 + us.fSeconds; k++) {
if (k < 2)
PrintTab2(chH, 3);
else
PrintGridCell(-2, j, 0, k);
if (k > 1)
AnsiColor(kDefault);
for (i0 = 0; i0 <= is.nObj; i0++) {
i = rgobjList[i0];
if (ignore[i])
continue;
PrintCh2(k < 2 ? chC : chV);
temp = grid->n[i][j];
if (k > 1 && i == j)
AnsiColor(kReverse);
if (k < 2)
PrintTab2(chH, 3);
else
PrintGridCell(i, j, 1 + us.fGridMidpoint, k);
AnsiColor(kDefault);
}
PrintL();
}
}
}
// Display all aspects between objects in the relationship comparison chart,
// one per line, in sorted order based on the total "power" of the aspects,
// as specified with the -r0 -a switch combination.
void ChartAspectRelation(void)
{
int ca[cAspect + 1], co[objMax];
char sz[cchSzDef], *pch;
int vcut = nLarge, icut, jcut, vhi, ihi, jhi, ahi, phi, v, i0, j0, i, j, k,
p, count = 0, nSav;
real ip, jp, rPowSum = 0.0, rT;
flag fDistance = us.fDistance && !us.fParallel;
ClearB((pbyte)ca, sizeof(ca));
ClearB((pbyte)co, sizeof(co));
loop {
vhi = -nLarge;
// Search for the next most powerful aspect in the aspect grid.
for (i0 = 0; i0 <= is.nObj; i0++) {
i = rgobjList[i0];
if (FIgnore(i))
continue;
for (j0 = 0; j0 <= is.nObj; j0++) {
j = rgobjList[j0];
if (FIgnore(j))
continue;
if (k = grid->n[i][j]) {
ip = RObjInf(i);
jp = RObjInf(j);
p = (int)(rAspInf[k]*(ip+jp)/2.0*
(1.0-RAbs(grid->v[i][j])/GetOrb(i, j, k))*10000.0);
#ifdef EXPRESS
// Adjust power with AstroExpression if one set.
if (FSzSet(us.szExpAspList)) {
ExpSetN(iLetterW, i);
ExpSetN(iLetterX, k);
ExpSetN(iLetterY, j);
ExpSetN(iLetterZ, p);
ParseExpression(us.szExpAspList);
p = NExpGet(iLetterZ);
}
#endif
switch (us.nAspectSort) {
default: v = p; break;
case aso: v = -NAbs((int)(grid->v[i][j]*3600.0)); break;
case asn: v = -(int)(grid->v[i][j]*3600.0); break;
case asO: v = -(j0*cObj + i0); break;
case asP: v = -(i0*cObj + j0); break;
case asA: v = -(k*cObj*cObj + j*cObj + i); break;
case asC: v = -(int)(cp1.obj[j]*3600.0); break;
case asD: v = -(int)(cp2.obj[i]*3600.0); break;
case asM: v = -(int)(Midpoint(cp1.obj[j], cp2.obj[i])*3600.0); break;
}
if ((v < vcut || (v == vcut && (i0 > icut ||
(i0 == icut && j0 > jcut)))) && v > vhi) {
vhi = v; ihi = i0; jhi = j0; ahi = k; phi = p;
}
}
}
}
if (vhi <= -nLarge) // Exit when no less powerful aspect found.
break;
vcut = vhi; icut = ihi; jcut = jhi;
i = rgobjList[ihi]; j = rgobjList[jhi];
count++; // Display the current aspect.
rPowSum += (real)phi/10000.0;
ca[ahi]++;
co[j]++; co[i]++;
#ifdef INTERPRET
if (us.fInterpret) { // Interpret it if -I in effect.
InterpretAspectRelation(j, i);
AnsiColor(kDefault);
continue;
}
#endif
sprintf(sz, "%3d: ", count); PrintSz(sz);
PrintAspect(j, planetval1(j), planetdir1(j), ahi,
i, planetval2(i), planetdir2(i), 'A');
rT = grid->v[i][j];
AnsiColor(rT < 0.0 ? kWhiteA : kLtGrayA);
if (fDistance) {
nSav = us.nDegForm; us.nDegForm = df360;
}
sprintf(sz, "- orb: %c%s", rgchAppSep[us.nAppSep*2 + (rT >= 0.0)],
SzDegree2(RAbs(rT)));
if (fDistance) {
us.nDegForm = nSav;
for (pch = sz; *pch; pch++)
;
pch[-1] = '%';
}
PrintSz(sz);
AnsiColor(kDkGreenA);
PrintSz(" - power: ");
sprintf(sz, us.fSeconds ? "%7.4f" : "%5.2f", (real)phi/10000.0);
PrintSz(sz); PrintL();
AnsiColor(kDefault);
}
#ifdef EXPRESS
// Send summary to AstroExpression if one set.
if (!us.fExpOff && FSzSet(us.szExpAspSumm)) {
ExpSetN(iLetterY, count);
ExpSetR(iLetterZ, rPowSum);
ParseExpression(us.szExpAspSumm);
}
#endif
PrintAspectSummary(ca, co, count, rPowSum);
}
// Display locations of all midpoints between objects in the relationship
// comparison chart, one per line, in sorted zodiac order from zero Aries
// onward, as specified with the -r0 -m switch combination.
void ChartMidpointRelation(void)
{
int cs[cSign + 1];
char sz[cchSzDef];
int icut, jcut, ilo, jlo, i, j, count = 0;
real rSpanSum = 0.0, mcut = -1.0, mlo, m, mid, dist, midalt;
ClearB((pbyte)cs, sizeof(cs));
loop {
mlo = rDegMax;
// Search for the next closest midpoint farther down in the zodiac.
for (i = 0; i <= is.nObj; i++) if (!FIgnore(i))
for (j = 0; j <= is.nObj; j++) if (!FIgnore(j)) {
m = ZFromS(grid->n[i][j]) + grid->v[i][j];
if ((m > mcut || (m == mcut && (i > icut ||
(i == icut && j > jcut)))) && m < mlo) {
ilo = i; jlo = j; mlo = m;
}
}
if (mlo >= rDegMax) // Exit when no midpoint farther in zodiac found.
break;
mcut = mlo; icut = ilo; jcut = jlo;
if (us.objRequire >= 0 && ilo != us.objRequire && jlo != us.objRequire)
continue;
if (!us.fHouse3D) {
mid = Midpoint(cp1.obj[ilo], cp2.obj[jlo]);
midalt = (cp1.alt[ilo] + cp2.alt[jlo]) / 2.0;
dist = MinDistance(cp1.obj[ilo], cp2.obj[jlo]);
} else {
SphRatio(cp1.obj[ilo], cp1.alt[ilo], cp2.obj[jlo], cp2.alt[jlo], 0.5,
&mid, &midalt);
dist = SphDistance(cp1.obj[ilo], cp1.alt[ilo],
cp2.obj[jlo], cp2.alt[jlo]);
}
#ifdef EXPRESS
// Skip current midpoint if AstroExpression says to do so.
if (!us.fExpOff && FSzSet(us.szExpMid)) {
ExpSetN(iLetterW, ilo);
ExpSetN(iLetterX, jlo);
ExpSetR(iLetterY, mid);
ExpSetR(iLetterZ, dist);
if (!NParseExpression(us.szExpMid))
continue;
}
#endif
count++; // Display the current midpoint.
cs[SFromZ(mlo)]++;
rSpanSum += dist;
#ifdef INTERPRET
if (us.fInterpret) { // Interpret it if -I in effect.
InterpretMidpointRelation(ilo, jlo);
AnsiColor(kDefault);
continue;
}
#endif
sprintf(sz, "%4d: ", count); PrintSz(sz);
PrintZodiac(mid);
PrintCh(' ');
if (us.fParallel) {
AnsiColor(kDefault);
PrintAltitude(midalt);
PrintCh(' ');
}
PrintAspect(ilo, cp1.obj[ilo], cp1.dir[ilo], 0,
jlo, cp2.obj[jlo], cp2.dir[jlo], 'M');
AnsiColor(kDefault);
PrintSz("- ");
PrintSz(SzDegree(dist));
if (us.fParallel && !us.fHouse3D) {
PrintCh(' ');
PrintSz(SzDegree(RAbs(cp1.alt[ilo] - cp2.alt[jlo])));
}
PrintSz(" degree span.\n");
}
PrintMidpointSummary(cs, count, rSpanSum);
}
// Calculate any of the various kinds of relationship charts. This involves
// computing and storing the planet and house positions for the "core" and
// "second" charts, and then combining them in the main single chart in the
// proper manner, e.g. for synastry, composite, time space midpoint charts.
void CastRelation(void)
{
byte ignoreSav[objMax];
int i, j, cChart;
real ratio, t1, t2, t, rSav;
flag fSav;
// Cast the six charts.
fSav = us.fProgress;
cChart = 2 - (FBetween(us.nRel, rcHexaWheel, rcTriWheel) ? us.nRel+1 : 0);
for (i = 1; i <= cChart; i++) {
ciCore = *rgpci[i];
#ifdef WIN
if (i == 1 && us.nRel == rcMidpoint)
ciCore = ciMain = ciSave;
#endif
if (i == 2 && us.nRel <= rcTransit) {
CopyRgb(ignore, ignoreSav, sizeof(ignore));
for (j = 0; j <= is.nObj; j++)
ignore[j] = ignore[j] && ignore2[j];
}
us.fProgress = (i == 1 && us.nRel == rcProgress ? fFalse :
(i == 2 && us.nRel == rcProgress ? fTrue : rgfProg[i]));
if (us.fProgress) {
is.JDp = MdytszToJulian(MM, DD, YY, TT, SS, ZZ);
ciCore = ciMain;
}
FProcessCommandLine(szWheel[i]);
if (FNoTimeOrSpace(ciCore)) {
cp0 = *rgpcp[i];
t = 0.0;
} else
t = CastChart(i);
if (i == 1) {
t1 = t;
rSav = is.MC;
} else if (i == 2)
t2 = t;
*rgpcp[i] = cp0;
if (i == 2 && us.nRel <= rcTransit)
CopyRgb(ignoreSav, ignore, sizeof(ignore));
}
us.fProgress = fSav;
ciCore = ciMain;
FProcessCommandLine(szWheel[0]);
is.MC = rSav;
// Now combine the two charts based on what relation we are doing.
// For the standard -r synastry chart, use the house cusps of chart1
// and the planet positions of chart2.
ratio = (real)us.nRatio1 / ((real)(us.nRatio1 + us.nRatio2));
if (us.nRel <= rcSynastry) {
for (i = 1; i <= cSign; i++)
chouse[i] = cp1.cusp[i];
// For the -rc composite chart, take the midpoints of the planets/houses.
} else if (us.nRel == rcComposite) {
j = Max(is.nObj, cuspHi);
for (i = 0; i <= j; i++) {
planet[i] = Ratio(cp1.obj[i], cp2.obj[i], ratio);
if (RAbs(cp2.obj[i] - cp1.obj[i]) > rDegHalf)
planet[i] = Mod(planet[i] + rDegMax*ratio);
planetalt[i] = Ratio(cp1.alt[i], cp2.alt[i], ratio);
ret[i] = Ratio(cp1.dir[i], cp2.dir[i], ratio);
}
for (i = 1; i <= cSign; i++) {
chouse[i] = Ratio(cp1.cusp[i], cp2.cusp[i], ratio);
if (RAbs(cp2.cusp[i] - cp1.cusp[i]) > rDegHalf)
chouse[i] = Mod(chouse[i] + rDegMax*ratio);
}
// Make sure don't have any 180 degree errors in house cusp complement
// pairs, which may happen if the cusps are far apart.
j = us.fPolarAsc ? sAri : sCap;
for (i = 1; i <= cSign; i++)
if (MinDistance(chouse[j], Mod(chouse[i]-ZFromS(i+3))) > rDegQuad)
chouse[i] = Mod(chouse[i]+rDegHalf);
for (i = 1; i <= cSign; i++)
if (RAbs(MinDistance(chouse[i], planet[oAsc - 1 + i])) > rDegQuad)
planet[oAsc - 1 + i] = Mod(planet[oAsc - 1 + i]+rDegHalf);
// For the -rm time space midpoint chart, calculate the midpoint time and
// place between the two charts and then recast for the new chart info.
} else if (us.nRel == rcMidpoint) {
is.T = Ratio(t1, t2, ratio);
t = (is.T*36525.0)+rRound; is.JD = RFloor(t)+2415020.0;
TT = RFract(t)*24.0;
ZZ = Ratio(Zon, ciTwin.zon, ratio);
SS = Ratio(Dst, ciTwin.dst, ratio);
TT -= ZZ - SS;
if (TT < 0.0) {
TT += 24.0; is.JD -= 1.0;
}
JulianToMdy(is.JD, &MM, &DD, &YY);
if (!us.fHouse3D) {
// Take midpoint of longitude and latitude separately.
OO = Ratio(Lon, ciTwin.lon, ratio);
if (RAbs(ciTwin.lon-Lon) > rDegHalf)
OO = Mod(OO+rDegMax*ratio);
AA = Ratio(Lat, ciTwin.lat, ratio);
} else {
// Take true midpoint along great circle between the two locations.
SphRatio(Lon, Lat, ciTwin.lon, ciTwin.lat, ratio, &OO, &AA);
}
ciMain = ciCore;
CastChart(0);
#ifndef WIN
us.nRel = rcNone; // Turn off so don't move to midpoint again.
#endif
// There are a couple of non-astrological charts, which only require the
// number of days that have passed between the two charts to be done.
} else {
is.JD = RAbs(t2-t1)*36525.0;
cp0 = cp1;
}
ComputeInHouses();
}
/*
******************************************************************************
** Other Chart Display Routines.
******************************************************************************
*/
// Given two objects and an aspect between them, or an object and a sign that
// it's entering, print if this is a "major" event, such as a season change or
// major lunar phase. This is called from the ChartInDay() searching and
// influence routines. Do an interpretation if need be too.
void PrintInDayEvent(int source, int aspect, int dest, int nVoid)
{
char sz[cchSzDef];
int nEclipse, nEclipse2;
real rPct;
flag fSwap;
// If the Sun changes sign, then print out if this is a season change.
if (aspect == aSig) {
if (source == oSun) {
AnsiColor(kWhiteA);
if (dest == sAri || dest == sLib) {
if ((dest == sAri) == (AA >= 0.0))
PrintSz(" (Spring Equinox)");
else
PrintSz(" (Autumn Equinox)");
} else if (dest == sCan || dest == sCap) {
if ((dest == sCan) == (AA >= 0.0))
PrintSz(" (Summer Solstice)");
else
PrintSz(" (Winter Solstice)");
}
}
} else if (aspect > 0 && !us.fParallel) {
fSwap = (dest == oSun);
if (fSwap)
SwapN(source, dest);
// Print if the present aspect is a New, Full, or Half Moon.
if (source == oSun && (dest == oMoo || FMoons(dest)) &&
(us.fMoonMove || ObjOrbit(dest) == us.objCenter)) {
if (aspect <= aSqu)
AnsiColor(kWhiteA);
if (aspect == aCon)
PrintSz(" (New Moon)");
else if (aspect == aOpp) {
PrintSz(" (Full Moon)");
// Full Moons may be a lunar eclipse.
if (us.fEclipse) {
nEclipse = NCheckEclipseLunar(us.objCenter, dest, oSun, &rPct);
if (nEclipse > etNone) {
AnsiColor(kWhiteA);
sprintf(sz, " (%s Lunar Eclipse", szEclipse[nEclipse]);
PrintSz(sz);
if (us.fSeconds) {
sprintf(sz, " %.0f%%", rPct); PrintSz(sz);
}
PrintSz(")");
}
}
} else if (aspect == aSqu)
PrintSz(" (Half Moon)");
} else if (us.fEclipse && aspect == aOpp) {
// Check for generic opposition that's an eclipse.
nEclipse = NCheckEclipseLunar(us.objCenter, dest, source, &rPct);
if (nEclipse > etNone) {
nEclipse2 = NCheckEclipseLunar(us.objCenter, source, dest, &rPct);
nEclipse = Max(nEclipse, nEclipse2);
AnsiColor(kWhiteA);
sprintf(sz, " (%s Occultation", szEclipse[nEclipse]);
PrintSz(sz);
if (us.fSeconds) {
sprintf(sz, " %.0f%%", rPct); PrintSz(sz);
}
PrintSz(")");
}
}
// Conjunctions may be a solar eclipse or other occultation.
if (us.fEclipse && aspect == aCon) {
nEclipse = NCheckEclipse(source, dest, &rPct);
if (nEclipse > etNone) {
AnsiColor(kWhiteA);
sprintf(sz, " (%s %s%s", szEclipse[nEclipse], source == oSun ?
"Solar " : "", source == oSun && (dest == oMoo || FMoons(dest)) ?
"Eclipse" : "Occultation"); PrintSz(sz);
if (us.fSeconds) {
sprintf(sz, " %.0f%%", rPct); PrintSz(sz);
}
PrintSz(")");
}
}
if (fSwap)
SwapN(source, dest);
}
// Print if the present aspect is the Moon going void of course.
if (nVoid >= 0) {
AnsiColor(kDefault);
sprintf(sz, " (v/c %d:%02d", nVoid / 3600, nVoid / 60 % 60); PrintSz(sz);
if (us.fSeconds) {
sprintf(sz, ":%02d", nVoid % 60); PrintSz(sz);
}
PrintCh(')');
}
PrintL();
#ifdef INTERPRET
if (us.fInterpret)
InterpretInDay(source, aspect, dest);
#endif
AnsiColor(kDefault);
}
// Given two objects and an aspect (or one object, and an event such as a sign
// or direction change) display the configuration in question. This is called
// by the many charts which list aspects among items, such as the -a aspect
// lists, -m midpoint lists, -d aspect in day search and -D influence charts,
// and -t transit search and -T influence charts.
void PrintAspect(int obj1, real pos1, real ret1, int asp,
int obj2, real pos2, real ret2, char chart)
{
char sz[cchSzDef];
KI ki;
real rDiff;
flag fPar = (us.fParallel && asp >= aCon) || asp == aAlt, fDis, fLon,
fSav = is.fSeconds, fWax;
fDis = us.fDistance && !us.fParallel && asp >= aCon &&
!(chart == 'm' || chart == 'M' ||
chart == 'd' || chart == 'e' || chart == 't' || chart == 'u');
fLon = !fPar && !fDis;
if (fDis) {
// Express distance values as proportions of each other from 0-100%.
if (pos1 > pos2) {
pos2 = pos2/pos1*99.999; pos1 = 99.999;
} else if (pos1 < pos2) {
pos1 = pos1/pos2*99.999; pos2 = 99.999;
} else
pos1 = pos2 = 99.999;
}
is.fSeconds = fFalse;
if (asp >= aCon && rgobjList2[obj1] > rgobjList2[obj2] &&
!(chart == 'A' || chart == 'M' || chart == 't' || chart == 'T' ||
chart == 'e' || chart == 'u' || chart == 'U' || chart == '8')) {
SwapN(obj1, obj2); SwapR(&pos1, &pos2); SwapR(&ret1, &ret2);
}
AnsiColor(kObjA[obj1]);
if (chart == 't' || chart == 'T')
PrintSz("trans ");
else if (chart == 'e' || chart == 'u' || chart == 'U')
PrintSz("progr ");
// Print name of first planet.
sprintf(sz, "%7.7s", szObjDisp[obj1]); PrintSz(sz);
ki = fLon ? kSignA(SFromZ(pos1)) : kDefault;
AnsiColor(ki);
sprintf(sz, " %c", ret1 > 0.0 ? '(' : (ret1 < 0.0 ? '[' : '<')); PrintSz(sz);
if (asp == aSig && ret1 > 0.0)
pos1 += 29.999;
else if (asp == aDeg)
pos1 = (real)obj2 * (rDegMax / (real)(cSign * us.nSignDiv));
if (!us.fSeconds) {
if (fLon) {
if (us.nDegForm == df360)
sprintf(sz, "%3d", (int)pos1);
else if (us.nDegForm == dfHM)
sprintf(sz, "%2dh", (int)pos1/15);
else if (us.nDegForm == dfNak)
sprintf(sz, "%.3s", szNakshatra[(int)(pos1 / (rDegMax/27.0)) + 1]);
else
sprintf(sz, "%.3s", szSignName[SFromZ(pos1)]);
} else if (fPar)
sprintf(sz, "%c%2d", pos1 < 0 ? '-' : '+', (int)RAbs(pos1));
else
sprintf(sz, "%2d%%", (int)pos1);
PrintSz(sz);
} else {
if (fLon)
PrintZodiac(pos1);
else if (fPar)
PrintAltitude(pos1);
else {
sprintf(sz, "%f", pos1); sprintf(sz+6, "%s", "%"); PrintSz(sz);
}
AnsiColor(ki);
}
sprintf(sz, "%c", ret1 > 0.0 ? ')' : (ret1 < 0.0 ? ']' : '>')); PrintSz(sz);
PrintCh(' ');
// Mark aspect with wax/wan for charts that don't already include it.
if (us.nAppSep == 2 &&
!(chart == 'a' || chart == 'A' || chart == 'm' || chart == 'M' ||
chart == 'D' || chart == 'T' || chart == 'U' || chart == '8')) {
if (asp > aOpp) {
rDiff = MinDifference(pos2, pos1);
if (chart == 't' || chart == 'T')
fWax = (rDiff >= 0.0);
else
fWax = (RSgn2(ret1 - ret2) * rDiff >= 0.0);
AnsiColor(fWax ? kWhiteA : kDkGrayA);
PrintCh(rgchAppSep[5-fWax]);
} else
PrintCh(' ');
}
// Print name of aspect or other event.
AnsiColor(asp > 0 ? kAspA[asp] : kWhiteA);
if (asp == aSig || asp == aHou)
sprintf(sz, "-->"); // Print a sign change.
else if (asp == aDir)
sprintf(sz, "S/%c", obj2 ? chRet : 'D'); // Print a direction change.
else if (asp == aDeg)
sprintf(sz, "At:"); // Print a degree change.
else if (asp == aAlt)
sprintf(sz, "LA%c", obj2 ? '+' : '-'); // Print a latitude extreme.
else if (asp == aLen)
sprintf(sz, "%s", obj2 ? "Apo" : "Per"); // Print a distance extreme.
else if (asp == aNod)
sprintf(sz, "LA0"); // Print at latitude zero.
else if (asp == aDis)
sprintf(sz, "EqD"); // Print at equal distance.
else if (asp == 0)
sprintf(sz, chart == 'm' ? "&" : "with");
else
sprintf(sz, "%s", SzAspectAbbrev(asp)); // Print an aspect.
PrintSz(sz);
if (asp != aDir && asp != aAlt)
PrintCh(' ');
// Print name of second planet or event target.
if (chart == 'A')
PrintSz("with ");
if (asp == aSig) {
AnsiColor(kSignA(obj2));
sprintf(sz, "%s", szSignName[obj2]); PrintSz(sz);
} else if (asp == aDeg) {
is.fSeconds = fSav;
PrintZodiac((real)obj2 * (rDegMax / (real)(cSign * us.nSignDiv)));
} else if (asp == aHou) {
AnsiColor(kSignA(obj2));
if (chart == 't' || chart == 'u' || chart == 'T' || chart == 'U')
PrintSz("natal ");
sprintf(sz, "%d%s 3D House", obj2, szSuffix[obj2]); PrintSz(sz);
} else if (asp == aNod) {
AnsiColor(kElemA[obj2*2+1]);
sprintf(sz, "%s", rgszDir[obj2*2]); PrintSz(sz);
} else if (asp >= 0 || asp == aDis) {
ki = fLon ? kSignA(SFromZ(pos2)) : kDefault;
AnsiColor(ki);
if (chart == 't' || chart == 'u' || chart == 'T' || chart == 'U')
PrintSz("natal ");
sprintf(sz, "%c", ret2 > 0.0 ? '(' : (ret2 < 0.0 ? '[' : '<'));
PrintSz(sz);
if (!us.fSeconds) {
if (fLon) {
if (us.nDegForm == df360)
sprintf(sz, "%3d", (int)pos2);
else if (us.nDegForm == dfHM)
sprintf(sz, "%2dh", (int)pos2/15);
else if (us.nDegForm == dfNak)
sprintf(sz, "%.3s", szNakshatra[(int)(pos2 / (rDegMax/27.0)) + 1]);
else
sprintf(sz, "%.3s", szSignName[SFromZ(pos2)]);
} else if (fPar)
sprintf(sz, "%c%2d", pos2 < 0 ? '-' : '+', (int)RAbs(pos2));
else
sprintf(sz, "%2d%%", (int)pos2);
PrintSz(sz);
} else {
if (fLon)
PrintZodiac(pos2);
else if (fPar)
PrintAltitude(pos2);
else {
sprintf(sz, "%f", pos2); sprintf(sz+6, "%s", "%"); PrintSz(sz);
}
AnsiColor(ki);
}
sprintf(sz, "%c ", ret2 > 0.0 ? ')' : (ret2 < 0.0 ? ']' : '>'));
PrintSz(sz);
AnsiColor(kObjA[obj2]);
sprintf(sz, "%.10s", szObjDisp[obj2]); PrintSz(sz);
}
if (chart == 'D' || chart == 'T' || chart == 'U' || chart == 'a' ||
chart == 'A' || chart == 'm' || chart == 'M' || chart == '8')
PrintTab(' ', 10-CchSz(szObjDisp[obj2]));
is.fSeconds = fSav;
}
// Based on the given chart information, display all the aspects taking place
// in the chart, as specified with the -D switch. The aspects are printed in
// order of influence determined by treating them as happening outside among
// transiting planets, such that rare outer planet aspects are given more
// power than common ones among inner planets. (This is almost identical to
// the -a list, except the influences are different.)
void ChartInDayInfluence(void)
{
int source[MAXINDAY], aspect[MAXINDAY], dest[MAXINDAY], ca[cAspect + 1],
co[objMax], occurcount = 0, i, j, k, l, nSav;
real power[MAXINDAY], rPowSum = 0.0, rT;
char sz[cchSzDef], *pch;
flag fDistance = us.fDistance && !us.fParallel, f;
ClearB((pbyte)ca, sizeof(ca));
ClearB((pbyte)co, sizeof(co));
// Go compute the aspects in the chart.
if (!FCreateGrid(fFalse))
return;
// Search through the grid and build up the list of aspects.
for (j = 1; j <= is.nObj; j++) {
if (FIgnore(j))
continue;
for (i = 0; i < j; i++) {
if (FIgnore(i) || (k = grid->n[i][j]) == 0 || occurcount >= MAXINDAY)
continue;
source[occurcount] = i; aspect[occurcount] = k; dest[occurcount] = j;
rT = grid->v[i][j];
power[occurcount] = (RTransitInf(i)/4.0) * (RTransitInf(j)/4.0) *
rAspInf[k]*(1.0-(real)RAbs(rT)/GetOrb(i, j, k));
rPowSum += power[occurcount];
ca[k]++;
co[i]++; co[j]++;
occurcount++;
}
}
// Sort aspects by order of influence.
for (i = 1; i < occurcount; i++) {
j = i-1;
while (j >= 0) {
k = j+1;
switch (us.nAspectSort) {
default: f = power[j] > power[k]; break;
case aso: f = RAbs(grid->v[source[j]][dest[j]]) <
RAbs(grid->v[source[k]][dest[k]]); break;
case asn: f = grid->v[source[j]][dest[j]] <
grid->v[source[k]][dest[k]]; break;
case asO: f = rgobjList2[source[j]]*cObj + rgobjList2[dest[j]] <
rgobjList2[source[k]]*cObj + rgobjList2[dest[k]]; break;
case asP: f = rgobjList2[dest[j]]*cObj + rgobjList2[source[j]] <
rgobjList2[dest[k]]*cObj + rgobjList2[source[k]]; break;
case asA: f = aspect[j]*cObj*cObj + source[j]*cObj + dest[j] <
aspect[k]*cObj*cObj + source[k]*cObj + dest[k]; break;
case asC: f = planet[source[j]] < planet[source[k]]; break;
case asD: f = planet[dest[j]] < planet[dest[k]]; break;
case asM: f = Midpoint(planet[dest[j]], planet[source[j]]) <
Midpoint(planet[dest[k]], planet[source[k]]); break;
}
if (f)
break;
SwapN(source[j], source[j+1]);
SwapN(aspect[j], aspect[j+1]);
SwapN(dest[j], dest[j+1]);
SwapR(&power[j], &power[j+1]);
j--;
}
}
// Now display each aspect line.
for (i = 0; i < occurcount; i++) {
sprintf(sz, "%3d: ", i+1); PrintSz(sz);
j = source[i]; k = aspect[i]; l = dest[i];
PrintAspect(j, planetval(j), planetdir(j), k,
l, planetval(l), planetdir(l), 'D');
rT = grid->v[j][l];
AnsiColor(rT < 0.0 ? kWhiteA : kLtGrayA);
if (fDistance) {
nSav = us.nDegForm; us.nDegForm = df360;
}
sprintf(sz, " - %s %s", szAppSep[us.nAppSep*2 + (rT >= 0.0)],
SzDegree2(RAbs(rT)));
if (fDistance) {
us.nDegForm = nSav;
for (pch = sz; *pch; pch++)
;
pch[-1] = '%';
}
PrintSz(sz);
AnsiColor(kDkGreenA);
PrintSz(" - power:");
sprintf(sz, is.fSeconds ? "%8.4f" : "%6.2f", power[i]); PrintSz(sz);
PrintInDayEvent(j, k, l, -1);
}
if (occurcount == 0)
PrintSz("Empty transit aspect list.\n");
PrintAspectSummary(ca, co, occurcount, rPowSum);
}
// Given an arbitrary day, determine what aspects are made between this
// transiting chart and the given natal chart, as specified with the -T
// switch, and display the transits in order sorted by influence.
void ChartTransitInfluence(flag fProg)
{
int source[MAXINDAY], aspect[MAXINDAY], dest[MAXINDAY], ca[cAspect + 1],
co[objMax], occurcount = 0, fProgress = us.fProgress, i, j, k, l, m, nSav;
real power[MAXINDAY], rPowSum = 0.0, rT;
char sz[cchSzDef], *pch;
byte ignoreSav[objMax];
flag fDistance = us.fDistance && !us.fParallel, f;
ClearB((pbyte)ca, sizeof(ca));
ClearB((pbyte)co, sizeof(co));
if (!FNoTimeOrSpace(ciTran)) {
PrintSz("Transits at: ");
i = DayOfWeek(MonT, DayT, YeaT);
sprintf(sz, "%.3s %s %s (%cT Zone %s)\n", szDay[i],
SzDate(MonT, DayT, YeaT, 3), SzTim(TimT), ChDst(DstT),
SzZone(ZonT)); PrintSz(sz);
}
// Cast the natal and transiting charts as with a relationship chart.
cp1 = cp0;
CopyRgb(ignore, ignoreSav, sizeof(ignore));
for (i = 0; i <= is.nObj; i++)
ignore[i] = ignore2[i];
ciCore = ciTran;
if (us.fProgress = fProg) {
is.JDp = MdytszToJulian(MM, DD, YY, TT, SS, ZZ);
ciCore = ciMain;
}
CastChart(0);
cp2 = cp0;
CopyRgb(ignoreSav, ignore, sizeof(ignore));
// Do a relationship aspect grid to get the transits. Have to make and
// restore two changes to get it right for this chart: (1) Make the natal
// planets have zero velocity so applying vs. separating is only a function