home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource1
/
ast40dos
/
charts.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-04
|
35KB
|
1,035 lines
/*
** Astrolog (Version 4.00) File: charts.c
**
** IMPORTANT NOTICE: the graphics database and chart display routines
** used in this program are Copyright (C) 1991-1993 by Walter D. Pullen
** (cruiser1@stein.u.washington.edu). Permission is granted to freely
** use and distribute these routines provided one doesn't sell,
** restrict, or profit from them in any way. Modification is allowed
** provided these notices remain with any altered or edited versions of
** the program.
**
** The main planetary calculation routines used in this program have
** been Copyrighted and the core of this program is basically a
** conversion to C of the routines created by James Neely as listed in
** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
** available from Matrix Software. The copyright gives us permission to
** use the routines for personal use but not to sell them or profit from
** them in any way.
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby
** (brianw@sounds.wa.com). Conditions are identical to those above.
**
** The extended accurate 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
** (alois@azur.ch). 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.
**
** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 12/31/1993.
*/
#include "astrolog.h"
/*
******************************************************************************
** Single Chart Display Subprograms.
******************************************************************************
*/
/* Fill out tables based on the number of unrestricted planets in signs by */
/* element, signs by mode, as well as other values such as the number of */
/* objects in yang vs. yin signs, in various house hemispheres (north/south */
/* and east/west), and the number in first six signs vs. second six signs. */
/* This is used by the -v chart listing and the sidebar in graphics charts. */
void CreateElemTable(elemode, elem, mo, tot, pos, abo, lef, lea)
int elemode[4][3], *elem, *mo, *tot, *pos, *abo, *lef, *lea;
{
int i, j;
*tot = *pos = *abo = *lef = *lea = 0; /* Initialize arrays */
for (i = 0; i < 4; i++) /* and variables to zero */
elem[i] = 0;
for (j = 0; j < 3; j++)
mo[j] = 0;
for (i = 0; i < 4; i++)
for (j = 0; j < 3; j++)
elemode[i][j] = 0;
/* Calculate number of objects in each element, mode, hemisphere, etc. */
for (i = 1; i <= total; i++) if (!ignore[i]) {
(*tot)++;
j = ZTOS(planet[i]);
elemode[(j-1)&3][(j-1)%3]++;
elem[(j-1)&3]++; mo[(j-1)%3]++;
*pos += (j & 1);
*lea += (j < _LIB);
j = inhouse[i];
*abo += (j >= _LIB);
*lef += (j < _CAN || j >= _CAP);
}
}
/* Print the straight listing of planet and house positions and specified */
/* by the -v switch, along with the element table, etc. */
void ChartLocation()
{
int elemode[4][3], elem[4], mo[3], pos, abo, lef, lea;
int count, i, j, k;
CreateElemTable(elemode, elem, mo, &count, &pos, &abo, &lef, &lea);
/* Print header showing time and date of the chart being displayed. */
AnsiColor(WHITE);
fprintf(S, "%s %s chart ", appname, VERSION);
if (Mon == -1)
fprintf(S, "(no time or space)\n");
else if (relation == DASHrc)
fprintf(S, "(composite)\n");
else {
i = (int) (FRACT(dabs(Tim))*100.0+ROUND);
j = (int) (FRACT(dabs(Zon))*100.0+ROUND);
fprintf(S, "for %s %s",
CharDate(Mon, Day, Yea, TRUE), CharTime((int)Tim, i));
fprintf(S, " (%c%.0f:%02d GMT) ",
Zon > 0.0 ? '-' : '+', dabs(Zon), j);
fprintf(S, "%s\n", CharLocation(Lon, Lat, 100.0));
}
#ifdef INTERPRET
if (interpret) { /* Print an interpretation if -I in effect. */
if (relation == DASHr)
InterpretSynastry(); /* Print synastry interpretaion for -r -I. */
else
InterpretLocation(); /* Do normal interpretation for just -v -I. */
return;
}
#endif
AnsiColor(DEFAULT);
fprintf(S, "Body Locat. Ret. Decl. Rul. House Rul. Veloc. ");
fprintf(S, "%s Houses.\n\n", systemname[housesystem]);
/* Ok, now print out each location of each object. */
for (i = 1, j = 1; i <= BASE; i++, j++) {
if (i > OBJECTS && (i <= C_HI || ignore[i]))
continue;
while (i <= OBJECTS && j <= OBJECTS && ignore[j])
j++;
if (i <= OBJECTS && j > OBJECTS)
PrintTab(' ', 51);
else {
if (i > OBJECTS)
j = i;
AnsiColor(objectansi[j]);
fprintf(S, "%-4.4s: ", objectname[j]);
PrintZodiac(planet[j]);
fprintf(S, " %c ", ret[j] >= 0.0 ? ' ' : 'R');
if (j <= THINGS || j > OBJECTS)
PrintAltitude(planetalt[i]);
else
fprintf(S, "_______");
fprintf(S, " (%c)", Dignify(j, ZTOS(planet[i])));
k = inhouse[j];
AnsiColor(signansi(k));
fprintf(S, " [%2d%c%c house]", k, post[k][0], post[k][1]);
AnsiColor(DEFAULT);
fprintf(S, " [%c] ", Dignify(j, k));
if ((j != _MOO || placalc) && (IsObject(j) || (j == _NOD && placalc)))
fprintf(S, RTOD(dabs(ret[j])) < 10.0 ? "%c%5.3f" : "%c%5.2f",
ret[i] < 0.0 ? '-' : '+', RTOD(dabs(ret[j])));
else
fprintf(S, "______");
}
/* For some lines, we have to append the house cusp positions. */
if (i <= SIGNS) {
fprintf(S, " - ");
AnsiColor(signansi(i));
fprintf(S, "House cusp %2d: ", i);
PrintZodiac(house[i]);
}
/* For some lines, we have to append the element table information. */
if (i == SIGNS+2)
fprintf(S, " Car Fix Mut TOT");
else if (i > SIGNS+2 && i < SIGNS+7) {
k = i-(SIGNS+2)-1;
AnsiColor(elemansi[k]);
fprintf(S, " %c%c%c%3d %3d %3d %3d",
element[k][0], element[k][1], element[k][2],
elemode[k][0], elemode[k][1], elemode[k][2], elem[k]);
AnsiColor(DEFAULT);
} else if (i == SIGNS+7)
fprintf(S, " TOT %2d %3d %3d %3d", mo[0], mo[1], mo[2], count);
else if (i == OBJECTS)
PrintTab(' ', 23);
else if (i >= U_LO)
fprintf(S, " Uranian #%d", i-U_LO+1);
switch (i-SIGNS-1) {
case 1: fprintf(S, " +:%2d", pos); break;
case 2: fprintf(S, " -:%2d", count-pos); break;
case 3: fprintf(S, " M:%2d", abo); break;
case 4: fprintf(S, " N:%2d", count-abo); break;
case 5: fprintf(S, " A:%2d", lef); break;
case 6: fprintf(S, " D:%2d", count-lef); break;
case 7: fprintf(S, "<:%2d", lea); break;
}
printl();
}
/* Do another loop to print out the stars in their specified order. */
if (universe) for (i = S_LO; i <= S_HI; i++) if (!ignore[i]) {
j = BASE+starname[i-BASE];
AnsiColor(objectansi[j]);
fprintf(S, "%.4s: ", objectname[j]);
PrintZodiac(planet[j]);
fprintf(S, " ");
PrintAltitude(planetalt[j]);
k = inhouse[j];
AnsiColor(signansi(k));
fprintf(S, " [%2d%c%c house]", k, post[k][0], post[k][1]);
AnsiColor(DEFAULT);
fprintf(S, " ______ Star #%2d: %5.2f\n", i-BASE, starbright[j-BASE]);
}
}
/* Print out the aspect and midpoint grid for a chart, as specified with the */
/* -g switch. (Each grid row takes up 4 lines of text.) */
void ChartGrid()
{
int x, y, r, x1, y1, temp;
#ifdef INTERPRET
if (interpret) { /* Print interpretation instead if -I in effect. */
InterpretGrid();
return;
}
#endif
for (y1 = 0, y = 1; y <= total; y++) if (!ignore[