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

📄 options.c

📁 占星术4.0源码
💻 C
📖 第 1 页 / 共 4 页
字号:
  else if (relation == DASHrc) {
    for (i = 1; i <= total; i++) {
      planet[i] = Midpoint(planet1[i], planet2[i]);
      planetalt[i] = (planetalt1[i]+planetalt2[i])/2.0;
      ret[i] = (ret1[i]+ret2[i])/2.0;
    }
    for (i = 1; i <= SIGNS; i++)
      house[i] = Midpoint(house1[i], house2[i]);

    /* Make sure we don't have any 180 degree errors in house cusp    */
    /* complement pairs, which may happen if the cusps are far apart. */

    for (i = 1; i <= SIGNS; i++)
      if (MinDistance(house[_CAP], Mod(house[i]-STOZ(i+3))) > DEGQUAD)
        house[i] = Mod(house[i]+DEGHALF);

  /* 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 (relation == DASHrm) {
    T = (t1+t2)/2.0;
    t = (T*36525.0)+ROUND; JD = floor(t)+2415020.0; TT = FRACT(t)*24.0;
    ZZ = (DecToDeg(zon)+DecToDeg(Zon))/2.0; ZZ = DegToDec(ZZ);
    TT = DecToDeg(TT)-DecToDeg(ZZ); TT = DegToDec(TT);
    if (TT < 0.0) {
      TT = DecToDeg(TT)+24.0; TT = DegToDec(TT); JD -= 1.0;
    }
    JulianToMdy(JD, &MM, &DD, &YY);
    OO = (DecToDeg(lon)+DecToDeg(Lon))/2.0;
    if (dabs(Lon-lon) > DEGHALF)
      OO = Mod(OO+DEGHALF);
    OO = DegToDec(OO);
    AA = (DecToDeg(lat)+DecToDeg(Lat))/2.0; AA = DegToDec(AA);
    SetMain(MM, DD, YY, TT, ZZ, OO, AA);
    CastChart(FALSE);

  /* 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
    JD = dabs(t2-t1)*36525.0;
  HousePlace();
}


/* 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 DisplayInDay      */
/* searching and influence routines. Go an interpretation if need be too. */

void PrintInDay(source, aspect, dest)
int source, aspect, dest;
{
  if (aspect == _SIG) {
    if (source == _SUN) {
      AnsiColor(WHITE);
      if (dest == 1)
        fprintf(S, " (Vernal Equinox)");     /* If the Sun changes sign, */
      else if (dest == 4)                    /* then print out if this   */
        fprintf(S, " (Summer Solstice)");    /* is a season change.      */
      else if (dest == 7)
        fprintf(S, " (Autumnal Equinox)");
      else if (dest == 10)
        fprintf(S, " (Winter Solstice)");
    }
  } else if (aspect > 0) {
    if (source == _SUN && dest == _MOO) {
      if (aspect <= _SQU)
        AnsiColor(WHITE);
      if (aspect == _CON)
        fprintf(S, " (New Moon)");     /* Print out if the present */
      else if (aspect == _OPP)         /* aspect is a New, Full,   */
        fprintf(S, " (Full Moon)");    /* or Half Moon.            */
      else if (aspect == _SQU)
        fprintf(S, " (Half Moon)");
    }
  }
  printl();

#ifdef INTERPRET
  if (interpret)
    InterpretInDay(source, aspect, dest);
#endif
  AnsiColor(DEFAULT);
}


/* 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 -m0 aspect lists, -m midpoint lists, -d aspect in day search and   */
/* influence charts, and -t transit search and influence charts.          */

void PrintAspect(obj1, sign1, ret1, asp, obj2, sign2, ret2, chart)
int obj1, sign1, ret1, asp, obj2, sign2, ret2;
char chart;
{
  int smart, a, s2;

  smart = smartcusp && IsCusp(obj2) && asp == _OPP;
  a = smart ? _CON : asp;
  s2 = smart ? sign1 : sign2;

  AnsiColor(objectansi[obj1]);
  if (chart == 't' || chart == 'T')
    fprintf(S, "trans ");
  else if (chart == 'e' || chart == 'u' || chart == 'U')
    fprintf(S, "progr ");
  fprintf(S, "%7.7s", objectname[obj1]);
  AnsiColor(signansi(sign1));
  fprintf(S, " %c%c%c%c%c",
    ret1 > 0 ? '(' : (ret1 < 0 ? '[' : '<'), SIGNAM(sign1),
    ret1 > 0 ? ')' : (ret1 < 0 ? ']' : '>'));
  AnsiColor(a > 0 ? aspectansi[a] : WHITE);
  printc(' ');
  if (a == _SIG)
    fprintf(S, "-->");                       /* Print a sign change. */
  else if (a == _DIR)
    fprintf(S, "S/%c", obj2 ? 'R' : 'D');    /* Print a direction change. */
  else if (a == 0)
    printf(chart == 'm' ? "&" : "with");
  else
    fprintf(S, "%s", aspectabbrev[a]);       /* Print an aspect. */
  printc(' ');
  if (chart == 'A')
    fprintf(S, "with ");
  if (a == _SIG) {
    AnsiColor(signansi(obj2));
    fprintf(S, "%s", signname[obj2]);
  } else if (a >= 0) {
    AnsiColor(signansi(s2));
    if (chart == 't' || chart == 'u' || chart == 'T' || chart == 'U')
      fprintf(S, "natal ");
    fprintf(S, "%c%c%c%c%c ",
      ret2 > 0 ? '(' : (ret2 < 0 ? '[' : '<'), SIGNAM(s2),
      ret2 > 0 ? ')' : (ret2 < 0 ? ']' : '>'));
    AnsiColor(smart ? signansi((obj2-15) - (obj2 < 23)) : objectansi[obj2]);
    if (smart) {
      fprintf(S, "%dth cusp", (obj2-15) - (obj2 < 23));
      if (obj2 < 23)
        printc(' ');
    } else
      fprintf(S, "%.10s", objectname[obj2]);
  }
  if (chart == 'D' || chart == 'T' || chart == 'U' ||
    chart == 'a' || chart == 'A' || chart == 'm' || chart == 'M')
    PrintTab(' ', 10-StringLen(objectname[obj2]));
}


/* Search through a day, and print out the times of exact aspects among the  */
/* planets during that day, as specified with the -d switch, as well as the  */
/* times when a planet changes sign or direction. To do this, we cast charts */
/* for the beginning and end of the day, or a part of a day, and do a linear */
/* equation check to see if anything exciting happens during the interval.   */
/* (This is probably the single most complicated procedure in the program.)  */

void DisplayInDaySearch(prog)
int prog;
{
  int time[MAXINDAY], source[MAXINDAY], aspect[MAXINDAY], dest[MAXINDAY],
    sign1[MAXINDAY], sign2[MAXINDAY], D1, D2, occurcount, division, div,
    i, j, k, l, s1, s2;
  real divsiz, d1, d2, e1, e2, f1, f2, g;

  /* If parameter 'prog' is set, look for changes in a progressed chart. */

  division = prog ? 1 : divisions;
  divsiz = 24.0/ (real) division*60.0;

  /* If -dm in effect, then search through the whole month, day by day. */

  if (exdisplay & DASHdm) {
    D1 = 1;
    if (prog && Mon2 == 0) {
      Mon2 = 1; D2 = DayInYear(Yea2);
    } else
      D2 = DayInMonth(prog ? Mon2 : Mon, prog ? Yea2 : Yea);
  } else
    D1 = D2 = Day;

  /* Start searching the day or days in question for exciting stuff. */

  for (Day2 = D1; Day2 <= D2; Day2++) {
    occurcount = 0;

    /* Cast chart for beginning of day and store it for future use. */

    SetCore(Mon, Day2, Yea, 0.0, Zon, Lon, Lat);
    if (progress = prog) {
      Jdp = (real)MdyToJulian(Mon2, DD, Yea2);
      SetCore(Mon, Day, Yea, Tim, Zon, Lon, Lat);
    }
    CastChart(TRUE);
    for (i = 1; i <= SIGNS; i++) {
      house2[i] = house[i];
      inhouse2[i] = inhouse[i];
    }
    for (i = 1; i <= total; i++) {
      planet2[i] = planet[i];
      ret2[i] = ret[i];
    }

    /* Now divide the day into segments and search each segment in turn. */
    /* More segments is slower, but has slightly better time accuracy.   */

    for (div = 1; div <= division; div++) {

      /* Cast the chart for the ending time of the present segment. The   */
      /* beginning time chart is copied from the previous end time chart. */

      SetCore(Mon, Day2, Yea,
        DegToDec(24.0*(real)div/(real)division), Zon, Lon, Lat);
      if (prog) {
        Jdp = (real)MdyToJulian(Mon2, DD+1, Yea2);
        SetCore(Mon, Day, Yea, Tim, Zon, Lon, Lat);
      }
      CastChart(TRUE);
      for (i = 1; i <= SIGNS; i++) {
        house1[i] = house2[i]; inhouse1[i] = inhouse2[i];
        house2[i] = house[i];  inhouse2[i] = inhouse[i];
      }
      for (i = 1; i <= total; i++) {
        planet1[i] = planet2[i]; ret1[i] = ret2[i];
        planet2[i] = planet[i];  ret2[i] = ret[i];
      }

      /* Now search through the present segment for anything exciting. */

      for (i = 1; i <= total; i++) if (!ignore[i] && (prog || IsThing(i))) {
        s1 = ZTOS(planet1[i])-1;
        s2 = ZTOS(planet2[i])-1;

        /* Does the current planet change into the next or previous sign? */

        if (!ignore[i] && s1 != s2 && !ignore[0]) {
          source[occurcount] = i;
          aspect[occurcount] = _SIG;
          dest[occurcount] = s2+1;
          time[occurcount] = (int) (MinDistance(planet1[i],
            (real) (ret1[i] >= 0.0 ? s2 : s1) * 30.0) /
            MinDistance(planet1[i], planet2[i])*divsiz) +
            (int) ((real) (div-1)*divsiz);
          sign1[occurcount] = sign2[occurcount] = s1+1;
          occurcount++;
        }

        /* Does the current planet go retrograde or direct? */

        if (!ignore[i] && (ret1[i] < 0.0) != (ret2[i] < 0.0) && !ignore2[0]) {
          source[occurcount] = i;
          aspect[occurcount] = _DIR;
          dest[occurcount] = ret2[i] < 0.0;
          time[occurcount] = (int) (dabs(ret1[i])/(dabs(ret1[i])+dabs(ret2[i]))
            *divsiz) + (int) ((real) (div-1)*divsiz);
          sign1[occurcount] = sign2[occurcount] = s1+1;
          occurcount++;
        }

        /* Now search for anything making an aspect to the current planet. */

        for (j = i+1; j <= total; j++) if (!ignore[j] && (prog || IsThing(j)))
          for (k = 1; k <= aspects; k++) {
            d1 = planet1[i]; d2 = planet2[i];
            e1 = planet1[j]; e2 = planet2[j];
            if (MinDistance(d1, d2) < MinDistance(e1, e2)) {
              SwapReal(&d1, &e1);
              SwapReal(&d2, &e2);
            }

            /* We are searching each aspect in turn. Let's subtract the  */
            /* size of the aspect from the angular difference, so we can */
            /* then treat it like a conjunction.                         */

            if (MinDistance(e1, Mod(d1-aspectangle[k])) <
                MinDistance(e2, Mod(d2+aspectangle[k]))) {
              e1 = Mod(e1+aspectangle[k]);
              e2 = Mod(e2+aspectangle[k]);
            } else {
              e1 = Mod(e1-aspectangle[k]);
              e2 = Mod(e2-aspectangle[k]);
            }

            /* Check to see if the aspect actually occurs during our    */
            /* segment, making sure we take into account if one or both */
            /* planets are retrograde or if they cross the Aries point. */

            f1 = e1-d1;
            if (dabs(f1) > DEGHALF)
              f1 -= Sgn(f1)*DEGREES;
            f2 = e2-d2;
            if (dabs(f2) > DEGHALF)
              f2 -= Sgn(f2)*DEGREES;
            if (MinDistance(Midpoint(d1, d2), Midpoint(e1, e2)) < DEGQUAD &&
              Sgn(f1) != Sgn(f2)) {
              source[occurcount] = i;
              aspect[occurcount] = k;
              dest[occurcount] = j;

              /* Horray! The aspect occurs sometime during the interval.   */
              /* Now we just have to solve an equation in two variables to */
              /* find out where the "lines" cross, i.e. the aspect's time. */

              f1 = d2-d1;
              if (dabs(f1) > DEGHALF)
                f1 -= Sgn(f1)*DEGREES;
              f2 = e2-e1;
              if (dabs(f2) > DEGHALF)
                f2 -= Sgn(f2)*DEGREES;
              g = (dabs(d1-e1) > DEGHALF ?
                (d1-e1)-Sgn(d1-e1)*DEGREES : d1-e1)/(f2-f1);
              time[occurcount] = (int) (g*divsiz) +
                (int) ((real) (div-1)*divsiz);
              sign1[occurcount] = (int) (Mod(planet1[i]+
                Sgn(planet2[i]-planet1[i])*
                (dabs(planet2[i]-planet1[i]) > DEGHALF ? -1 : 1)*
                dabs(g)*MinDistance(planet1[i], planet2[i]))/30.0)+1;
              sign2[occurcount] = (int) (Mod(planet1[j]+
                Sgn(planet2[j]-planet1[j])*
                (dabs(planet2[j]-planet1[j]) > DEGHALF ? -1 : 1)*
                dabs(g)*MinDistance(planet1[j], planet2[j]))/30.0)+1;
              occurcount++;
            }
          }
      }
    }

    /* After all the aspects, etc, in the day have been located, sort   */
    /* them by time at which they occur, so we can print them in order. */

    for (i = 1; i < occurcount; i++) {
      j = i-1;
      while (j >= 0 && time[j] > time[j+1]) {
        SWAP(source[j], source[j+1]);
        SWAP(aspect[j], aspect[j+1]);
        SWAP(dest[j], dest[j+1]);
        SWAP(time[j], time[j+1]);
        SWAP(sign1[j], sign1[j+1]); SWAP(sign2[j], sign2[j+1]);
        j--;
      }
    }

    /* Finally, loop through and display each aspect and when it occurs. */

    for (i = 0; i < occurcount; i++) {
      s1 = time[i]/60;
      s2 = time[i]-s1*60;
      j = Day2;
      if (prog) {
        l = Mon2;
        while (j > (k = DayInMonth(l, Yea2))) {
          j -= k;
          l++;
        }
      }
      SetSave(prog ? l : Mon, j, prog ? Yea2 : Yea,
        DegToDec((real)time[i] / 60.0), Zon, Lon, Lat);
      k = DayOfWeek(prog ? l : Mon, j, prog ? Yea2 : Yea);
      AnsiColor(rainbowansi[k + 1]);
      fprintf(S, "(%c%c%c) ", DAYNAM(k));
      AnsiColor(DEFAULT);
      fprintf(S, "%s %s ",
        CharDate(prog ? l : Mon, j, prog ? Yea2 : Yea, FALSE),
        CharTime(s1, s2));
      PrintAspect(source[i], sign1[i],
        (int)Sgn(ret1[source[i]])+(int)Sgn(ret2[source[i]]),
        aspect[i], dest[i], sign2[i],
        (int)Sgn(ret1[dest[i]])+(int)Sgn(ret2[dest[i]]), prog ? 'e' : 'd');
      PrintInDay(source[i], aspect[i], dest[i]);
    }
  }
}


/* 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 -m0 list, except the influences are different.) */

void DisplayInDayInfluence()
{
  int source[MAXINDAY], aspect[MAXINDAY], dest[MAXINDAY];
  real power[MAXINDAY];
  int occurcount = 0, i, j, k, l, m;

  /* Go compute the aspects in the chart. */

  i = exdisplay;
  exdisplay |= DASHga;    /* We always want applying vs. separating orbs. */
  CreateGrid(FALSE);
  exdisplay = i;

  /* Search through the grid and build up the list of aspects. */

  for (j = 2; j <= total; j++) {
    if (ignore[j])
      continue;
    for (i = 1; i < j; i++) {
      if (ignore[i] || (k = grid->n[i][j]) == 0 || occurcount >= MAXINDAY)
        continue;
      if (smartcusp && k > _OPP && IsCusp(j))
        continue;
      source[occurcount] = i; aspect[occurcount] = k; dest[occurcount] = j;
      l = grid->v[i][j];
      power[occurcount] =
        ((i <= BASE ? transitinf[i] : 2.0)/4.0)*
        ((j <= BASE ? transitinf[j] : 2.0)/4.0)*
        aspectinf[k]*(1.0-(real)abs(l)/60.0/Orb(i, j, k));
      occurcount++;
    }
  }

  /* Sort aspects by order of influence. */

  for (i = 1; i < occurcount; i++) {
    j = i-1;
    while (j >= 0 && power[j] < power[j+1]) {
      SWAP(source[j], source[j+1]);
      SWAP(aspect[j], aspect[j+1]);
      SWAP(dest[j], dest[j+1]);
      SwapReal(&power[j], &power[j+1]);
      j--;
    }
  }

⌨️ 快捷键说明

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