⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 charts.c

📁 占星术4.0源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    for (j = 1; j <= total; j++) if (j != i && !ignore[j])
      for (k = 1; k <= total; k++) if (k != i && k != j && !ignore[k]) {

        /* Is there a Stellium among the current three planets? */

        if (i < j && j < k && grid->n[i][j] == _CON &&
            grid->n[i][k] == _CON && grid->n[j][k] == _CON) {
          count++;
          PrintGrand('.', i, j, k, l);

        /* Is there a Grand Trine? */

        } else if (i < j && j < k && grid->n[i][j] == _TRI &&
            grid->n[i][k] == _TRI && grid->n[j][k] == _TRI) {
          count++;
          PrintGrand('t', i, j, k, l);

        /* Is there a T-Square? */

        } else if (j < k && grid->n[j][k] == _OPP &&
            grid->n[MIN(i, j)][MAX(i, j)] == _SQU &&
            grid->n[MIN(i, k)][MAX(i, k)] == _SQU) {
          count++;
          PrintGrand('s', i, j, k, l);

        /* Is there a Yod? */

        } else if (j < k && grid->n[j][k] == _SEX &&
            grid->n[MIN(i, j)][MAX(i, j)] == _INC &&
            grid->n[MIN(i, k)][MAX(i, k)] == _INC) {
          count++;
          PrintGrand('y', i, j, k, l);
        }
        for (l = 1; l <= total; l++) if (!ignore[l]) {

          /* Is there a Grand Cross among the current four planets? */

          if (i < j && i < k && i < l && j < l && grid->n[i][j] == _SQU &&
              grid->n[MIN(j, k)][MAX(j, k)] == _SQU &&
              grid->n[MIN(k, l)][MAX(k, l)] == _SQU &&
              grid->n[i][l] == _SQU &&
              MinDistance(planet[i], planet[k]) > 150.0 &&
              MinDistance(planet[j], planet[l]) > 150.0) {
            count++;
            PrintGrand('g', i, j, k, l);

          /* Is there a Cradle? */

          } else if (i < l && grid->n[MIN(i, j)][MAX(i, j)] == _SEX &&
              grid->n[MIN(j, k)][MAX(j, k)] == _SEX &&
              grid->n[MIN(k, l)][MAX(k, l)] == _SEX &&
              MinDistance(planet[i], planet[l]) > 150.0) {
            count++;
            PrintGrand('c', i, j, k, l);
          }
        }
      }
  if (!count)
    fprintf(S, "No major configurations in aspect grid.\n");
}


/* This is subprocedure of ChartWheel(). Here we print out the location */
/* of a particular house cusp as well as what house cusp number it is.  */

void PrintHouse(i, left)
int i, left;
{
  if (!left)
    PrintZodiac(house[i]);
  AnsiColor(signansi(i));
  fprintf(S, "<%d>", i);
  if (left)
    PrintZodiac(house[i]);
  else
    AnsiColor(DEFAULT);
}


/* Another subprocedure of ChartWheel(). Here we print out one line in a */
/* particular house cell (which may be blank).                           */

void PrintWheelSlot(obj, wheelcols)
int obj, wheelcols;
{
  if (obj) {
    AnsiColor(objectansi[obj]);
    fprintf(S, " %c%c%c ", OBJNAM(obj));  /* Print planet and its position. */
    PrintZodiac(planet[obj]);
    fprintf(S, "%c ", ret[obj] < 0.0 ? 'r' : ' ');
    PrintTab(' ', WHEELCOLS-14-1);
  } else
    PrintTab(' ', wheelcols-1);       /* This particular line is blank. */
}


/* Display all the objects in a wheel format on the screen, as specified */
/* with the -w switch. The wheel is divided into the 12 houses and the   */
/* planets are placed accordingly.                                       */

void ChartWheel()
{
  byte wheel[SIGNS][WHEELROWS];
  int wheelcols, count = 0, i, j, k, l;

  /* If the seconds (-b0) flag is set, we'll print all planet and house    */
  /* locations to the nearest zodiac second instead of just to the minute. */

  seconds = -seconds;
  wheelcols = WHEELCOLS + (seconds < 0)*4;

  for (i = 0; i < SIGNS; i++)
    for (j = 0; j < wheelrows; j++)    /* Clear out array from the */
      wheel[i][j] = 0;                 /* last time we used it.    */

  /* This section of code places each object in the wheel house array. */

  for (i = 1; i <= total && count < wheelrows*12; i++) {
    if (ignore[i] || !(i < _MC || i == OBJECTS || i > C_HI))
      continue;

    /* Try to put object in its proper house. If no room, */
    /* then overflow over to the succeeding house.        */

    for (j = inhouse[i]-1; j < SIGNS; j = j < SIGNS ? (j+1)%SIGNS : j) {

      /* Now try to find the proper place in the house to put the object. */
      /* This is in sorted order, although a check is made for 0 Aries.   */

      if (wheel[j][wheelrows-1] > 0)
        continue;
      l = house[j+1] > house[Mod12(j+2)];
      for (k = 0; wheel[j][k] > 0 &&
           (planet[i] >= planet[wheel[j][k]] ||
            (l && planet[i] < DEGHALF && planet[wheel[j][k]] > DEGHALF)) &&
           !(l && planet[i] > DEGHALF && planet[wheel[j][k]] < DEGHALF); k++)
        ;

      /* Actually insert object in proper place. */

      if (wheel[j][k] <= 0)
        wheel[j][k] = i;
      else {
        for (l = wheelrows-1; l > k; l--)
          wheel[j][l] = wheel[j][l-1];
        wheel[j][k] = i;
      }
      count++;
      j = SIGNS;
    }
  }

  /* Now, if this is really the -w switch and not -w0, then reverse the */
  /* order of objects in western houses for more intuitive reading.     */

  if (!(exdisplay & DASHw0))
    for (i = 3; i < 9; i++)
      for (j = 0; j < wheelrows/2; j++) {
        k = wheelrows-1-j;
        l = wheel[i][j]; wheel[i][j] = wheel[i][k]; wheel[i][k] = l;
      }

  /* Here we actually print the wheel and the objects in it. */

  printc(BOXNW); PrintTab(BOXH, WHEELCOLS-8); PrintHouse(11, TRUE);
  PrintTab(BOXH, WHEELCOLS-11); PrintHouse(10, TRUE);
  PrintTab(BOXH, WHEELCOLS-10); PrintHouse(9, TRUE);
  PrintTab(BOXH, wheelcols-4); fprintf(S, "%c\n", BOXNE);
  for (i = 0; i < wheelrows; i++) {
    for (j = 10; j >= 7; j--) {
      printc(BOXV); PrintWheelSlot(wheel[j][i], wheelcols);
    }
    fprintf(S, "%c\n", BOXV);
  }
  PrintHouse(12, TRUE); PrintTab(BOXH, WHEELCOLS-11);
  printc(BOXC); PrintTab(BOXH, wheelcols-1); printc(BOXJN);
  PrintTab(BOXH, wheelcols-1); printc(BOXC); PrintTab(BOXH, WHEELCOLS-10);
  PrintHouse(8, FALSE); printl();
  for (i = 0; i < wheelrows; i++) {
    printc(BOXV); PrintWheelSlot(wheel[11][i], wheelcols); printc(BOXV);

    /* For some rows, we have to insert the chart header information. */

    if (i) {
      PrintTab(' ', wheelcols-11-(i == 2 && !eurotime));
      if (i == 1)
        fprintf(S, "%s (%s) chart", appname, VERSION);
      else if (i == 2) {
        j = DayOfWeek(Mon, Day, Yea);
        k = (int) (FRACT(dabs(Tim))*100.0+ROUND);
        fprintf(S, "%c%c%c %s %s", DAYNAM(j), CharDate(Mon, Day, Yea, 2),
          CharTime((int)floor(Tim), k));
      } else if (i == 3) {
        fprintf(S, "%c%02d:", Zon > 0.0 ? '-' : '+', (int)dabs(Zon));
        j = (int) (FRACT(dabs(Zon))*100.0+ROUND);
        fprintf(S, "%02d %s", j, CharLocation(Lon, Lat, 100.0));
      } else
        PrintTab(' ', 21);
      PrintTab(' ', wheelcols-11-(i == 2 && !eurotime));

    } else
      PrintTab(' ', wheelcols*2-1);
    printc(BOXV); PrintWheelSlot(wheel[6][i], wheelcols);
    fprintf(S, "%c\n", BOXV);
  }
  PrintHouse(1, TRUE); PrintTab(BOXH, WHEELCOLS-10);
  printc(BOXJW); PrintTab(' ', wheelcols-11);
  fprintf(S, "%s", systemname[housesystem]);
  PrintTab(' ', 14-StringLen(systemname[housesystem]));
  fprintf(S, "Houses."); PrintTab(' ', wheelcols-11); printc(BOXJE);
  PrintTab(BOXH, WHEELCOLS-10); PrintHouse(7, FALSE); printl();
  for (i = 0; i < wheelrows; i++) {
    printc(BOXV); PrintWheelSlot(wheel[0][i], wheelcols); printc(BOXV);
    if (i == 0) {
      PrintTab(' ', wheelcols-12);
      fprintf(S, "Julian Day = %9.2f", JulianDayFromTime(T));
      PrintTab(' ', wheelcols-12);
    } else
      PrintTab(' ', wheelcols*2-1);
    printc(BOXV); PrintWheelSlot(wheel[5][i], wheelcols);
    fprintf(S, "%c\n", BOXV);
  }
  PrintHouse(2, TRUE); PrintTab(BOXH, WHEELCOLS-10);
  printc(BOXC); PrintTab(BOXH, wheelcols-1); printc(BOXJS);
  PrintTab(BOXH, wheelcols-1); printc(BOXC);
  PrintTab(BOXH, WHEELCOLS-10); PrintHouse(6, FALSE); printl();
  for (i = 0; i < wheelrows; i++) {
    for (j = 1; j <= 4; j++) {
      printc(BOXV); PrintWheelSlot(wheel[j][i], wheelcols);
    }
    fprintf(S, "%c\n", BOXV);
  }
  printc(BOXSW); PrintTab(BOXH, wheelcols-4); PrintHouse(3, FALSE);
  PrintTab(BOXH, WHEELCOLS-10); PrintHouse(4, FALSE);
  PrintTab(BOXH, WHEELCOLS-10); PrintHouse(5, FALSE);
  PrintTab(BOXH, WHEELCOLS-7); fprintf(S, "%c\n", BOXSE);
  seconds = -seconds;
}


/* Display all aspects between objects in the chart, one per line, in       */
/* sorted order based on the total "power" of the aspect, as specified with */
/* the -m0 switch. The same influences used for -I charts are used here.    */

void ChartAspect()
{
  int pcut = 30000, icut, jcut, phi, ihi, jhi, ahi, p, i, j, k, count = 0;
  real ip, jp;

  loop {
    phi = -1;

    /* Search for the next most powerful aspect in the aspect grid. */

    for (i = 2; i <= total; i++) if (!ignore[i])
      for (j = 1; j < i; j++) if (!ignore[j])
        if (k = grid->n[j][i]) {
          ip = i <= OBJECTS ? objectinf[i] : 2.5;
          jp = j <= OBJECTS ? objectinf[j] : 2.5;
          p = (int) (aspectinf[k]*(ip+jp)/2.0*
            (1.0-dabs((real)(grid->v[j][i]))/60.0/aspectorb[k])*1000.0);
          if ((p < pcut || (p == pcut && (i > icut ||
            (i == icut && j > jcut)))) && p > phi) {
            ihi = i; jhi = j; phi = p; ahi = k;
          }
        }
    if (phi < 0)    /* Exit when no less powerful aspect found. */
      break;
    pcut = phi; icut = ihi; jcut = jhi;
    count++;                               /* Display the current aspect.   */
#ifdef INTERPRET
    if (interpret) {                       /* Interpret it if -I in effect. */
      InterpretAspect(jhi, ihi);
      continue;
    }
#endif
    fprintf(S, "%3d: ", count);
    PrintAspect(jhi, ZTOS(planet[jhi]), (int)Sgn(ret[jhi]), ahi,
      ihi, ZTOS(planet[ihi]), (int)Sgn(ret[ihi]), 'a');
    k = grid->v[jhi][ihi];
    AnsiColor(k < 0 ? WHITE : LTGRAY);
    fprintf(S, " - orb: %c%d%c%02d'",
      exdisplay & DASHga ? (k < 0 ? 'a' : 's') : (k < 0 ? '-' : '+'),
      abs(k)/60, DEGR1, abs(k)%60);
    AnsiColor(DKGREEN);
    fprintf(S, " - power:%6.2f\n", (real) phi/1000.0);
    AnsiColor(DEFAULT);
  }
}


/* Display locations of all midpoints between objects in the chart, */
/* one per line, in sorted zodiac order from zero Aries onward, as  */
/* specified with the -m switch.                                    */

void ChartMidpoint()
{
  int mcut = -1, icut, jcut, mlo, ilo, jlo, m, i, j, count = 0;

  loop {
    mlo = 21600;

    /* Search for the next closest midpoint farther down in the zodiac. */ 

    for (i = 1; i < total; i++) if (!ignore[i])
      for (j = i+1; j <= total; j++) if (!ignore[j]) {
        m = (grid->n[j][i]-1)*30*60 + grid->v[j][i];
        if ((m > mcut || (m == mcut && (i > icut ||
          (i == icut && j > jcut)))) && m < mlo) {
          ilo = i; jlo = j; mlo = m;
        }
      }
    if (mlo >= 21600)    /* Exit when no midpoint farther in zodiac found. */
      break;
    mcut = mlo; icut = ilo; jcut = jlo;
    count++;                               /* Display the current midpoint. */
#ifdef INTERPRET
    if (interpret) {                       /* Interpret it if -I in effect. */
      InterpretMidpoint(ilo, jlo);
      continue;
    }
#endif
    fprintf(S, "%4d: ", count);
    PrintZodiac((real) mlo/60.0);
    printc(' ');
    PrintAspect(ilo, ZTOS(planet[ilo]), (int)Sgn(ret[ilo]), 0,
      jlo, ZTOS(planet[jlo]), (int)Sgn(ret[jlo]), 'm');
    AnsiColor(DEFAULT);
    fprintf(S, "-%4d degree span.\n",
      (int) MinDistance(planet[ilo], planet[jlo]));
  }
}


/* Display locations of the objects on the screen with respect to the local */
/* horizon, as specified with the -Z switch.                                */

void ChartHorizon()
{
  real lon, lat, sx, sy, vx, vy,
    lonz[TOTAL+1], latz[TOTAL+1], azi[TOTAL+1], alt[TOTAL+1];
  int i, j, k, tot;

  lon = DTOR(Mod(Lon)); lat = DTOR(Lat);
  tot = universe ? total : BASE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -