sweph 2.10.1-a1 → 2.10.2-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,13 +74,17 @@
74
74
  # define MY_TRUE 1 /* for use in other defines, before TRUE is defined */
75
75
  # define MY_FALSE 0 /* for use in other defines, before TRUE is defined */
76
76
 
77
+ #ifdef __CYGWIN__ // following T. Mack Jan/July 2021
78
+ # undef __GNUC__
79
+ #endif
80
+
77
81
  /* TLS support
78
82
  *
79
83
  * Sun Studio C/C++, IBM XL C/C++, GNU C and Intel C/C++ (Linux systems) -> __thread
80
84
  * Borland, VC++ -> __declspec(thread)
81
85
  */
82
86
  #if !defined(TLSOFF) && !defined( __APPLE__ ) && !defined(WIN32) && !defined(DOS32)
83
- #if defined( __GNUC__ )
87
+ #if defined( __GNUC__ ) || defined( __CYGWIN__ )
84
88
  #define TLS __thread
85
89
  #else
86
90
  #define TLS __declspec(thread)
@@ -4678,7 +4678,7 @@ static int read_const(int ifno, char *serr)
4678
4678
  /* MPC number and name; will be analyzed below:
4679
4679
  * search "asteroid name" */
4680
4680
  while(*sp == ' ') sp++;
4681
- while(isdigit(*sp)) sp++;
4681
+ while(isdigit((int) *sp)) sp++;
4682
4682
  sp++;
4683
4683
  i = (int) (sp - s);
4684
4684
  strncpy(sastnam, s, lastnam+i); // fixed 19-nov-19
@@ -8399,3 +8399,311 @@ const char *CALL_CONV swe_get_current_file_data(int ifno, double *tfstart, doubl
8399
8399
  return pfp->fnam;
8400
8400
  }
8401
8401
 
8402
+ #define CROSS_PRECISION (1 / 3600000.0) // one milliarc sec
8403
+
8404
+ /*************************************************
8405
+ * compute Sun'scrossing over some longitude
8406
+ * flag covers the following bits as used by swe_calc():
8407
+ SEFLG_HELCTR 0 = geocentric, SUN, 1 = heliocentric, EARTH
8408
+ SEFLG_TRUEPOS 0 = apparent positions, 1 = true positions
8409
+ SEFLG_NONUT 0 = do nutation (true equinox of date)
8410
+ * returns juldate of the next crossing, with jd > jd_et
8411
+ * The returned time is ephemeris time; to get UT we must do
8412
+ * jd_ut = jd - deltat(jd) or use swe_solcross_ut.
8413
+ * Errors are indicated by returning a jd < jd_et!
8414
+ *************************************************/
8415
+ double CALL_CONV swe_solcross(double x2cross, double jd_et, int flag, char *serr)
8416
+ {
8417
+ double x[6], xlp, dist;
8418
+ double jd;
8419
+ int ipl = SE_SUN;
8420
+ /*
8421
+ * compute the SUN at start date, and then estimate the crossing date
8422
+ */
8423
+ flag |= SEFLG_SPEED;
8424
+ if (swe_calc(jd_et, ipl, flag, x, serr) < 0)
8425
+ return jd_et - 1;
8426
+ xlp = 360.0 / 365.24; /* mean solar speed */
8427
+ dist = swe_degnorm(x2cross - x[0]);
8428
+ jd = jd_et + dist / xlp;
8429
+ for(;;) {
8430
+ if (swe_calc(jd, ipl, flag, x, serr) < 0)
8431
+ return jd_et - 1;
8432
+ dist = swe_difdeg2n(x2cross, x[0]);
8433
+ jd += dist / x[3];
8434
+ if (fabs(dist) < CROSS_PRECISION) break;
8435
+ }
8436
+ return jd;
8437
+ }
8438
+
8439
+ /*************************************************
8440
+ * compute Sun'scrossing over some longitude, in UT
8441
+ * flag covers the following bits as used by swe_calc():
8442
+ SEFLG_HELCTR 0 = geocentric, SUN, 1 = heliocentric, EARTH
8443
+ SEFLG_TRUEPOS 0 = apparent positions, 1 = true positions
8444
+ SEFLG_NONUT 0 = do nutation (true equinox of date)
8445
+ * returns juldate of the next crossing, with jd > jd_ut
8446
+ * The returned time is universal time;
8447
+ * Errors are indicated by returning a jd < jd_ut!
8448
+ *************************************************/
8449
+ double CALL_CONV swe_solcross_ut(double x2cross, double jd_ut, int flag, char *serr)
8450
+ {
8451
+ double x[6], xlp, dist;
8452
+ double jd;
8453
+ int ipl = SE_SUN;
8454
+ /*
8455
+ * compute the SUN at start date, and then estimate the crossing date
8456
+ */
8457
+ flag |= SEFLG_SPEED;
8458
+ if (swe_calc_ut(jd_ut, ipl, flag, x, serr) < 0)
8459
+ return jd_ut - 1;
8460
+ xlp = 360.0 / 365.24; /* mean solar speed */
8461
+ dist = swe_degnorm(x2cross - x[0]);
8462
+ jd = jd_ut + dist / xlp;
8463
+ for(;;) {
8464
+ if (swe_calc_ut(jd, ipl, flag, x, serr) < 0)
8465
+ return jd_ut - 1;
8466
+ dist = swe_difdeg2n(x2cross, x[0]);
8467
+ jd += dist / x[3];
8468
+ if (fabs(dist) < CROSS_PRECISION) break;
8469
+ }
8470
+ return jd;
8471
+ }
8472
+
8473
+ /*************************************************
8474
+ * compute Moon's crossing over some longitude
8475
+ * flag covers the following bits as used by swe_calc():
8476
+ SEFLG_TRUEPOS 0 = apparent positions, 1 = true positions
8477
+ SEFLG_NONUT 0 = do nutation (true equinox of date)
8478
+ * returns juldate of the next crossing, with jd > jd_et
8479
+ * The returned time is ephemeris time; to get UT we must do
8480
+ * jd_ut = jd - deltat(jd);
8481
+ * Errors are indicated by returning a jd < jd_et!
8482
+ *************************************************/
8483
+ double CALL_CONV swe_mooncross(double x2cross, double jd_et, int flag, char *serr)
8484
+ {
8485
+ double x[6], xlp, dist;
8486
+ double jd;
8487
+ int ipl = SE_MOON;
8488
+ /*
8489
+ * compute the SUN at start date, and then estimate the crossing date
8490
+ */
8491
+ flag |= SEFLG_SPEED;
8492
+ if (swe_calc(jd_et, ipl, flag, x, serr) < 0)
8493
+ return jd_et - 1;
8494
+ xlp = 360.0 / 27.32; /* mean lunar speed */
8495
+ dist = swe_degnorm(x2cross - x[0]);
8496
+ jd = jd_et + dist / xlp;
8497
+ for(;;) {
8498
+ if (swe_calc(jd, ipl, flag, x, serr) < 0)
8499
+ return jd_et - 1;
8500
+ dist = swe_difdeg2n(x2cross, x[0]);
8501
+ jd += dist / x[3];
8502
+ if (fabs(dist) < CROSS_PRECISION) break;
8503
+ }
8504
+ return jd;
8505
+ }
8506
+
8507
+ /*************************************************
8508
+ * compute Moon's crossing over some longitude
8509
+ * flag covers the following bits as used by swe_calc_ut():
8510
+ SEFLG_TRUEPOS 0 = apparent positions, 1 = true positions
8511
+ SEFLG_NONUT 0 = do nutation (true equinox of date)
8512
+ SEFLG_SIDEREAL 0 = do tropical
8513
+ * returns juldate of the next crossing, with jd > jd_ut
8514
+ * The returned time is UT
8515
+ * Errors are indicated by returning a jd < jd_ut!
8516
+ * If sidereal is chosen, default mode is Fagan/Bradley. For different aynamshas,
8517
+ * swe_set_sid_mode() must be called first.
8518
+ *************************************************/
8519
+ double CALL_CONV swe_mooncross_ut(double x2cross, double jd_ut, int flag, char *serr)
8520
+ {
8521
+ double x[6], xlp, dist;
8522
+ double jd;
8523
+ int ipl = SE_MOON;
8524
+ /*
8525
+ * compute the SUN at start date, and then estimate the crossing date
8526
+ */
8527
+ flag |= SEFLG_SPEED;
8528
+ if (swe_calc_ut(jd_ut, ipl, flag, x, serr) < 0)
8529
+ return jd_ut - 1;
8530
+ xlp = 360.0 / 27.32; /* mean lunar speed */
8531
+ dist = swe_degnorm(x2cross - x[0]);
8532
+ jd = jd_ut + dist / xlp;
8533
+ for(;;) {
8534
+ if (swe_calc_ut(jd, ipl, flag, x, serr) < 0)
8535
+ return jd_ut - 1;
8536
+ dist = swe_difdeg2n(x2cross, x[0]);
8537
+ jd += dist / x[3];
8538
+ if (fabs(dist) < CROSS_PRECISION) break;
8539
+ }
8540
+ return jd;
8541
+ }
8542
+
8543
+ /*************************************************
8544
+ * compute next Moon crossing over node, by finding zero latitude crossing
8545
+ * returns juldate of the next crossing, with jd > jd_et
8546
+ * The returned time is ephemeris time; to get UT we must do
8547
+ * jd_ut = jd - deltat(jd);
8548
+ * Errors are indicated by returning a jd < jd_et!
8549
+ *************************************************/
8550
+ double CALL_CONV swe_mooncross_node(double jd_et, int flag, double *xlon, double *xla, char *serr)
8551
+ {
8552
+ double x[6], xlat, dist;
8553
+ double jd;
8554
+ int ipl = SE_MOON;
8555
+ flag |= SEFLG_SPEED;
8556
+ if (swe_calc(jd_et, ipl, flag, x, serr) < 0)
8557
+ return jd_et - 1;
8558
+ xlat = x[1];
8559
+ jd = jd_et + 1;
8560
+ for(;;) { // get to sign change
8561
+ if (swe_calc(jd, ipl, flag, x, serr) < 0)
8562
+ return jd_et - 1;
8563
+ if ((x[1] >= 0 && xlat < 0) || (x[1] < 0 && xlat > 0))
8564
+ break;
8565
+ jd += 1;
8566
+ }
8567
+ dist = x[1];
8568
+ for(;;) {
8569
+ jd -= dist / x[4];
8570
+ if (swe_calc(jd, ipl, flag, x, serr) < 0)
8571
+ return jd_et - 1;
8572
+ dist = x[1];
8573
+ if (fabs(dist) < CROSS_PRECISION) {
8574
+ *xlon = x[0];
8575
+ *xla = x[1];
8576
+ break;
8577
+ }
8578
+ }
8579
+ return jd;
8580
+ }
8581
+ /*************************************************
8582
+ * compute next Moon crossing over node in UT, by finding zero latitude crossing
8583
+ * returns juldate of the next crossing, with jd > jd_ut
8584
+ * The returned time is universal time;
8585
+ * Errors are indicated by returning a jd < jd_ut!
8586
+ *************************************************/
8587
+ double CALL_CONV swe_mooncross_node_ut(double jd_ut, int flag, double *xlon, double *xla, char *serr)
8588
+ {
8589
+ double x[6], xlat, dist;
8590
+ double jd;
8591
+ int ipl = SE_MOON;
8592
+ flag |= SEFLG_SPEED;
8593
+ if (swe_calc_ut(jd_ut, ipl, flag, x, serr) < 0)
8594
+ return jd_ut - 1;
8595
+ xlat = x[1];
8596
+ jd = jd_ut + 1;
8597
+ for(;;) { // get to sign change
8598
+ if (swe_calc_ut(jd, ipl, flag, x, serr) < 0)
8599
+ return jd_ut - 1;
8600
+ if ((x[1] >= 0 && xlat < 0) || (x[1] < 0 && xlat > 0))
8601
+ break;
8602
+ jd += 1;
8603
+ }
8604
+ dist = x[1];
8605
+ for(;;) {
8606
+ jd -= dist / x[4];
8607
+ if (swe_calc_ut(jd, ipl, flag, x, serr) < 0)
8608
+ return jd_ut - 1;
8609
+ dist = x[1];
8610
+ if (fabs(dist) < CROSS_PRECISION) {
8611
+ *xlon = x[0];
8612
+ *xla = x[1];
8613
+ break;
8614
+ }
8615
+ }
8616
+ return jd;
8617
+ }
8618
+
8619
+ /*************************************************
8620
+ * compute a planets heliocentric crossing over some longitude
8621
+ * returns juldate of the next crossing, with jd > jd_et if dir >= 0,
8622
+ * or the previous crossing, if dir < 0.
8623
+ * The returned time is ephemeris time.
8624
+ * Errors are indicated by returning ERR;
8625
+ * This should only be used for rought house entry or exit times.
8626
+ *************************************************/
8627
+ int32 CALL_CONV swe_helio_cross(int ipl, double x2cross, double jd_et, int iflag, int dir, double *jd_cross, char *serr)
8628
+ {
8629
+ double x[6], xlp, dist;
8630
+ double jd;
8631
+ int flag = iflag | SEFLG_SPEED | SEFLG_HELCTR;
8632
+ if (ipl == SE_SUN
8633
+ || ipl == SE_MOON
8634
+ || (ipl >= SE_MEAN_NODE && ipl <= SE_OSCU_APOG)
8635
+ || (ipl >= SE_INTP_APOG && ipl < SE_NPLANETS)
8636
+ ) {
8637
+ char snam[AS_MAXCH];
8638
+ swe_get_planet_name(ipl, snam);
8639
+ if (serr != NULL) sprintf(serr, "swe_helio_cross: not possible for object %d = %s", ipl, snam);
8640
+ return ERR;
8641
+ }
8642
+ if (swe_calc(jd_et, ipl, flag, x, serr) < 0)
8643
+ return ERR;
8644
+ xlp = x[3];
8645
+ if (ipl == SE_CHIRON)
8646
+ xlp = 0.01971; // use mean speeed
8647
+ dist = swe_degnorm(x2cross - x[0]);
8648
+ if (dir >= 0) {
8649
+ jd = jd_et + dist / xlp;
8650
+ } else {
8651
+ dist = 360.0 - dist;
8652
+ jd = jd_et - dist / xlp;
8653
+ }
8654
+ for(;;) {
8655
+ if (swe_calc(jd, ipl, flag, x, serr) < 0)
8656
+ return ERR;
8657
+ dist = swe_difdeg2n(x2cross, x[0]);
8658
+ jd += dist / x[3];
8659
+ if (fabs(dist) < CROSS_PRECISION) break;
8660
+ }
8661
+ *jd_cross = jd;
8662
+ return OK;
8663
+ }
8664
+
8665
+ /*************************************************
8666
+ * compute a planets heliocentric crossing over some longitude
8667
+ * returns juldate of the next crossing, with jd > jd_ut if dir >= 0,
8668
+ * or the previous crossing, if dir < 0.
8669
+ * The returned time is Universal time.
8670
+ * Errors are indicated by returning ERR;
8671
+ * This should only be used for rought house entry or exit times.
8672
+ *************************************************/
8673
+ int32 CALL_CONV swe_helio_cross_ut(int ipl, double x2cross, double jd_ut, int iflag, int dir, double *jd_cross, char *serr)
8674
+ {
8675
+ double x[6], xlp, dist;
8676
+ double jd;
8677
+ int flag = iflag | SEFLG_SPEED | SEFLG_HELCTR;
8678
+ if (ipl == SE_SUN
8679
+ || ipl == SE_MOON
8680
+ || (ipl >= SE_MEAN_NODE && ipl <= SE_OSCU_APOG)
8681
+ || (ipl >= SE_INTP_APOG && ipl < SE_NPLANETS)
8682
+ ) {
8683
+ char snam[AS_MAXCH];
8684
+ swe_get_planet_name(ipl, snam);
8685
+ if (serr != NULL) sprintf(serr, "swe_helio_cross: not possible for object %d = %s", ipl, snam);
8686
+ return ERR;
8687
+ }
8688
+ if (swe_calc_ut(jd_ut, ipl, flag, x, serr) < 0)
8689
+ return ERR;
8690
+ xlp = x[3];
8691
+ if (ipl == SE_CHIRON)
8692
+ xlp = 0.01971; // use mean speeed
8693
+ dist = swe_degnorm(x2cross - x[0]);
8694
+ if (dir >= 0) {
8695
+ jd = jd_ut + dist / xlp;
8696
+ } else {
8697
+ dist = 360.0 - dist;
8698
+ jd = jd_ut - dist / xlp;
8699
+ }
8700
+ for(;;) {
8701
+ if (swe_calc_ut(jd, ipl, flag, x, serr) < 0)
8702
+ return ERR;
8703
+ dist = swe_difdeg2n(x2cross, x[0]);
8704
+ jd += dist / x[3];
8705
+ if (fabs(dist) < CROSS_PRECISION) break;
8706
+ }
8707
+ *jd_cross = jd;
8708
+ return OK;
8709
+ }