Changeset 6425
- Timestamp:
- Feb 13, 2006, 2:09:27 PM (20 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 6 edited
-
astro/psEarthOrientation.c (modified) (49 diffs)
-
astro/psEarthOrientation.h (modified) (3 diffs)
-
astro/psSphereOps.h (modified) (2 diffs)
-
sys/psMemory.c (modified) (2 diffs)
-
types/psList.c (modified) (11 diffs)
-
types/psList.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r6328 r6425 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-02- 06 21:57:04$10 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-02-14 00:09:26 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 356 356 psSphere *sun) 357 357 { 358 //Check for valid inputs 358 359 PS_ASSERT_PTR_NON_NULL(actual, NULL); 359 360 PS_ASSERT_PTR_NON_NULL(sun, NULL); 360 361 361 362 psSphere *temp = psSphereAlloc(); 362 // calculating the apparent angle from the actual angle and the sun position363 364 363 psCube* sunVector = psSphereToCube(sun); 365 364 psCube* actualVector = psSphereToCube(actual); 366 365 367 366 // use dot product to calculate the angle of separation 368 // N.B., assuming the psSphereToCube function returns a unit vector.369 // double theta = acos(sunVector->x*actualVector->x +370 367 double dotProd = (sunVector->x*actualVector->x + 371 368 sunVector->y*actualVector->y + sunVector->z*actualVector->z); … … 378 375 theta = acos(dotProd); 379 376 380 // theta = acos( cos(sun->d)*cos(actual->d)*cos(sun->r-actual->r) + sin(sun->r)*sin(actual->r) );381 382 377 printf(" Theta = %.13g\n", theta); 383 // theta = acos(-theta);384 // printf("\n Theta = %lf\n", theta);385 378 double r0 = PS_AU * tan(theta); 386 379 printf(" r0 = %.19e\n", r0); … … 389 382 // make sure the deflection is not greater than 1.75 arcsec 390 383 double limit = SEC_TO_RAD(1.75); 391 printf(" deflection = %.13g\n", deflection);392 //printf(" limit = %lf\n", limit);393 384 if (deflection > limit) { 394 // deflection = limit;395 385 //if deflection is greater than limit, the light rays will hit the sun 396 386 psWarning("Invalid positions. Light ray will not be seen on earth.\n"); … … 400 390 } 401 391 402 /* if (apparent == NULL) { 403 apparent = psSphereAlloc(); 404 } else { 405 apparent->r = 0.0; 406 apparent->d = 0.0; 407 apparent->rErr = 0.0; 408 apparent->dErr = 0.0; 409 } 410 */ 392 411 393 if (apparent != NULL) { 412 394 psFree(apparent); 413 395 } 414 396 // bend the actual vector away from the sun vector by deflection angle. 415 // XXX: Not sure how to do this. Dave thinks the formula should be:416 // theta = atan(r0/d)*tan(deflection), phi = thete/tan(deflection)417 397 theta = 0.0; 418 398 double phi = 0.0; … … 477 457 double t4 = t*t*t*t; 478 458 479 // N.B., the following formulae are from the ADD 480 // Mean Anomaly of the Moon 459 // The following formulae are from the ADD (& s5.8 of IERS Technical Note 32): 481 460 double F[14]; 461 // Mean Anomaly of the Moon (l) 482 462 F[0] = DEG_TO_RAD(134.96340251) + 483 463 SEC_TO_RAD(1717915923.2178)*t + … … 485 465 SEC_TO_RAD(0.051635)*t3 - 486 466 SEC_TO_RAD(0.00024470)*t4; 487 488 // Mean Anomaly of the Sun 467 // Mean Anomaly of the Sun (l') 489 468 F[1] = DEG_TO_RAD(357.52910918) + 490 469 SEC_TO_RAD(129596581.0481)*t - … … 492 471 SEC_TO_RAD(0.000136)*t3 - 493 472 SEC_TO_RAD(0.00001149)*t4; 494 495 // L - Omega 473 // L - Omega (L = Mean Longitude of the Moon, Omega = F4) 496 474 F[2] = DEG_TO_RAD(93.27209062) + 497 475 SEC_TO_RAD(1739527262.8478)*t - … … 499 477 SEC_TO_RAD(0.001037)*t3 + 500 478 SEC_TO_RAD(0.00000417)*t4; 501 502 // Mean Elongation of the Moon from the Sun 479 // Mean Elongation of the Moon from the Sun (D) 503 480 F[3] = DEG_TO_RAD(297.85019547) + 504 481 SEC_TO_RAD(1602961601.2090)*t - … … 506 483 SEC_TO_RAD(0.006593)*t3 - 507 484 SEC_TO_RAD(0.00003169)*t4; 508 509 // Mean Longitude of the Ascending Node of the Moon 485 // Mean Longitude of the Ascending Node of the Moon (Omega) 510 486 F[4] = DEG_TO_RAD(125.04455501) - 511 487 SEC_TO_RAD(6962890.5431)*t + … … 513 489 SEC_TO_RAD(0.007702)*t3 - 514 490 SEC_TO_RAD(0.0000593)*t4; 515 491 //F5-F13 are the mean longitudes of the planets 516 492 F[5] = 4.402608842 + 2608.7903141574*t; 517 493 F[6] = 3.176146697 + 1021.3285546211*t; … … 528 504 eocInitialized = p_psEOCInit(); 529 505 if(!eocInitialized) { 530 // XXX: Move error message.531 506 psError(PS_ERR_UNKNOWN, false, 532 507 "Could not initialize EOC tables -- check data files."); … … 534 509 } 535 510 } 536 537 511 // calculate the polynomial portion first 538 512 double X = psPolynomial1DEval(xPoly,t); 539 513 double Y = psPolynomial1DEval(yPoly,t); 540 514 double S = psPolynomial1DEval(sPoly,t); 541 515 //Units from the table & coefficients are in micro-arcseconds so convert to radians. 542 516 X = SEC_TO_RAD(X * 1e-6); 543 517 Y = SEC_TO_RAD(Y * 1e-6); … … 545 519 546 520 // now calculate the non-poly portion from the tables 547 psF64* cols[17]; 521 psF64* cols[17]; //Used to store all of the table information from tab5.2?.dat 548 522 for (int lcv = 0; lcv < 17; lcv++) { 549 523 cols[lcv] = ((psVector*)(xTable->data[lcv]))->data.F64; 550 524 } 525 //Get the number of rows in the table and loop through the non-poly contributions. 551 526 int numRows = ((psVector*)(xTable->data[0]))->n; 552 527 for (int lcv = 0; lcv < numRows; lcv++) { 553 // arg = sum w_(i,j,k)*F_k554 528 double arg = 0.0; 529 //Get the argument- from the table and corresponding F-value. Convert to radians. 555 530 for (int k = 0; k < 14; k++) { 556 531 arg += cols[k+3][lcv]*F[k]; 557 532 } 558 double tj = pow(t,cols[0][lcv]); 559 double as = cols[1][lcv]; 560 double ac = cols[2][lcv]; 561 // printf("as-x, ac-x, = %.13g, %.13g\n", as, ac); 562 as = SEC_TO_RAD(as) * 1e-6; 563 ac = SEC_TO_RAD(ac) * 1e-6; 564 // X += as*tj*sin(arg) + ac*tj*cos(arg); 565 X += (as*tj*sin(arg) + ac*cos(arg)) * tj; 566 } 567 568 for (int lcv = 0; lcv < 17; lcv++) { 569 cols[lcv] = ((psVector*)(yTable->data[lcv]))->data.F64; 570 } 571 numRows = ((psVector*)(yTable->data[0]))->n; 572 for (int lcv = 0; lcv < numRows; lcv++) { 573 // arg = sum w_(i,j,k)*F_k 574 double arg = 0.0; 575 for (int k = 0; k < 14; k++) { 576 arg += cols[k+3][lcv]*F[k]; 577 } 533 //The order of t for each part is specified by a column in the tab.dat files. 578 534 double tj = pow(t,cols[0][lcv]); 579 535 double as = cols[1][lcv]; … … 581 537 as = SEC_TO_RAD(as) * 1e-6; 582 538 ac = SEC_TO_RAD(ac) * 1e-6; 583 584 // Y += as*tj*sin(arg) + ac*tj*cos(arg); 585 Y += (as*tj*sin(arg) + ac*cos(arg)) * tj; 586 } 587 539 X += (as*tj*sin(arg) + ac*cos(arg)) * tj; 540 } 541 //Do the same procedure from the previous 15 lines for Y. 588 542 for (int lcv = 0; lcv < 17; lcv++) { 589 cols[lcv] = ((psVector*)( sTable->data[lcv]))->data.F64;590 } 591 numRows = ((psVector*)( sTable->data[0]))->n;543 cols[lcv] = ((psVector*)(yTable->data[lcv]))->data.F64; 544 } 545 numRows = ((psVector*)(yTable->data[0]))->n; 592 546 for (int lcv = 0; lcv < numRows; lcv++) { 593 // arg = sum w_(i,j,k)*F_k594 547 double arg = 0.0; 595 548 for (int k = 0; k < 14; k++) { … … 601 554 as = SEC_TO_RAD(as) * 1e-6; 602 555 ac = SEC_TO_RAD(ac) * 1e-6; 603 604 // S += as*tj*sin(arg) + ac*tj*cos(arg); 556 Y += (as*tj*sin(arg) + ac*cos(arg)) * tj; 557 } 558 //Again for S. 559 for (int lcv = 0; lcv < 17; lcv++) { 560 cols[lcv] = ((psVector*)(sTable->data[lcv]))->data.F64; 561 } 562 numRows = ((psVector*)(sTable->data[0]))->n; 563 for (int lcv = 0; lcv < numRows; lcv++) { 564 double arg = 0.0; 565 for (int k = 0; k < 14; k++) { 566 arg += cols[k+3][lcv]*F[k]; 567 } 568 double tj = pow(t,cols[0][lcv]); 569 double as = cols[1][lcv]; 570 double ac = cols[2][lcv]; 571 as = SEC_TO_RAD(as) * 1e-6; 572 ac = SEC_TO_RAD(ac) * 1e-6; 605 573 S += (as*tj*sin(arg) + ac*cos(arg)) * tj; 606 574 } 607 575 608 // now, the tables for S actually gives S + XY/2, so let's get the real S now576 //the tables for S actually gives S + XY/2, so let's get the real S now. (from ADD) 609 577 S -= X*Y/2.0; 610 578 611 // psEarthPole* pole = psAlloc(sizeof(psEarthPole));579 //Create the output psEarthPole and set the corresponding component values. 612 580 psEarthPole* pole = psEarthPoleAlloc(); 613 581 pole->x = X; … … 621 589 psTimeBulletin bulletin) 622 590 { 591 // Check for null parameter or invalid bulletin 623 592 PS_ASSERT_PTR_NON_NULL(time,NULL); 624 593 PS_ASSERT_INT_WITHIN_RANGE(bulletin, PS_IERS_A, PS_IERS_B, NULL); 625 626 psEarthPole *out = psEarthPoleAlloc(); 627 out->x = 0.0; 628 out->y = 0.0; 629 out->s = 0.0; 630 594 //Convert the input time to MJD. If NAN is returned, return NULL for the function. 631 595 double MJD = psTimeToMJD(time); 632 596 if (MJD == NAN) { … … 635 599 return NULL; 636 600 } 637 /* 638 if (MJD < 41684.0 || MJD > 53334.0) { 639 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 640 "Invalid time input. Date, %lf, is out of range (41684-53334)\n", MJD); 641 return out; 642 } 643 */ 601 //Allocate space for the psEarthPole output. 602 psEarthPole *out = psEarthPoleAlloc(); 603 644 604 // Check if EOC data loaded 645 605 if(!eocInitialized) { 646 606 eocInitialized = p_psEOCInit(); 647 607 if(!eocInitialized) { 648 // XXX: Move error message.649 608 psError(PS_ERR_UNKNOWN, false, 650 609 "Could not initialize EOC tables -- check data files."); … … 653 612 } 654 613 614 //Load the data table and store in the corresponding, newly-allocated vectors. 655 615 psF64* cols[5]; 656 616 for (int colNum = 0; colNum < 5; colNum++) { … … 658 618 } 659 619 int numRows = ((psVector*)(iersTable->data[0]))->n; 660 /*661 for (int rowNum = 0; rowNum < numRows; rowNum++) {662 if ( (MJD - cols[0][rowNum]) < 1.0 ) {663 if (bulletin == PS_IERS_A) {664 out->x = cols[1][rowNum];665 out->y = cols[2][rowNum];666 out->x = SEC_TO_RAD(out->x) * 1e-3;667 out->y = SEC_TO_RAD(out->y) * 1e-3;668 rowNum = numRows;669 } else {670 out->x = cols[3][rowNum];671 out->y = cols[4][rowNum];672 out->x = SEC_TO_RAD(out->x) * 1e-3;673 out->y = SEC_TO_RAD(out->y) * 1e-3;674 rowNum = numRows;675 }676 }677 }678 */679 620 psVector *X = psVectorAlloc(numRows, PS_TYPE_F64); 680 621 psVector *Y = psVectorAlloc(numRows, PS_TYPE_F64); … … 694 635 } 695 636 637 //The following uses lagrange interpolation to calculate the corrections to X & Y. 696 638 double xOut = 0.0; 697 639 double yOut = 0.0; … … 724 666 } 725 667 } 668 //Convert the values from milli-arcsecond to radian. 726 669 out->x = SEC_TO_RAD(xOut) * 1e-3; 727 670 out->y = SEC_TO_RAD(yOut) * 1e-3; … … 736 679 { 737 680 int i; 738 psSphereRot *new = (psSphereRot*)psAlloc(sizeof(psSphereRot)); 739 // psMemSetDeallocator(new, (psFreeFunc)sphereRotFree); 740 //Convert rotation matrix to quaternions 681 psSphereRot *new = psSphereRotAlloc(0.0, 0.0, 0.0); 682 new->q3 = 0.0; 683 684 //Convert rotation matrix to quaternions. Formula directly from ADD. 741 685 double diag_sum[3]; 742 686 int maxi; … … 783 727 psSphereRot* psSphereRot_CEOtoGCRS(const psEarthPole *pole) 784 728 { 729 // Check for null parameter 785 730 PS_ASSERT_PTR_NON_NULL(pole,NULL); 786 731 double A[3][3]; … … 788 733 789 734 //Setup the rotation matrix and scalar value, a, as outlined by the ADD 790 //XXX: Used formula for rotation matrix D from mathworld for z-axis rotation791 735 double a = 1.0 / (1.0 + sqrt(1.0 - (pole->x*pole->x + pole->y*pole->y) ) ); 792 /* A[0][0] = (1.0 - a*pole->x*pole->x)*cos(pole->s) - a*pole->x*pole->y*sin(pole->s);793 A[0][1] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s);794 A[0][2] = pole->x*cos(pole->s) + pole->y*sin(pole->s);795 A[1][0] = -(1.0 - a*pole->x*pole->x)*sin(pole->s) - a*pole->x*pole->y*cos(pole->s);796 A[1][1] = a*pole->x*pole->y*sin(pole->s) + (1.0 - a*pole->y*pole->y)*cos(pole->s);797 A[1][2] = -pole->x*sin(pole->s) + pole->y*cos(pole->s);798 A[2][0] = -pole->x;799 A[2][1] = -pole->y;800 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y);801 */802 803 736 A[0][0] = (1.0 - a*pole->x*pole->x)*cos(pole->s) - a*pole->x*pole->y*sin(pole->s); 804 737 A[1][0] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s); … … 811 744 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y); 812 745 813 double x, y, s; 814 x = pole->x; 815 y = pole->y; 816 s = pole->s; 817 /* A[0][0] = (1.0 - a*x*x)*cos(s) + a*x*y*sin(s); 818 A[0][1] = (1.0 - a*x*x)*sin(s) - a*x*y*cos(s); 819 A[0][2] = x; 820 A[1][0] = -a*x*y*cos(s) - (1.0 - a*y*y)*sin(s); 821 A[1][1] = -a*x*y*sin(s) + (1.0 - a*y*y)*cos(s); 822 A[1][2] = y; 823 A[2][0] = -x*cos(s) + y*sin(s); 824 A[2][1] = -x*sin(s) - y*cos(s); 825 A[2][2] = 1.0 - a * (x*x + y*y); 826 */ 827 /* A[0][0] = (1.0 - a*x*x)*cos(s) + a*x*y*sin(s); 828 A[1][0] = (1.0 - a*x*x)*sin(s) - a*x*y*cos(s); 829 A[2][0] = x; 830 A[0][1] = -a*x*y*cos(s) - (1.0 - a*y*y)*sin(s); 831 A[1][1] = -a*x*y*sin(s) + (1.0 - a*y*y)*cos(s); 832 A[2][1] = y; 833 A[0][2] = -x*cos(s) + y*sin(s); 834 A[1][2] = -x*sin(s) - y*cos(s); 835 A[2][2] = 1.0 - a * (x*x + y*y); 836 */ 746 //Convert the rotation matrix to a psSphereRot (quaternions) 837 747 out = rotMatrix_To_Quat(A); 838 748 … … 843 753 psEarthPole *tidalCorr) 844 754 { 755 // Check for null parameter 845 756 PS_ASSERT_PTR_NON_NULL(time,NULL); 846 psTime *in = psTimeAlloc(time->type);847 *in = *time;757 //Create a copy of the input time that can be manipulated/changed (input time is const). 758 psTime *in = p_psTimeCopy(time); 848 759 if (in->type != PS_TIME_UT1) { 849 760 in = psTimeConvert(in, PS_TIME_UT1); 850 761 } 762 //Check if tidal corrections should be included. 763 //If so, make sure values are positive and in the correct range. 851 764 if (tidalCorr != NULL && tidalCorr->s != 0.0) { 852 765 int nsec = in->nsec + (int)(tidalCorr->s * 1e9); 766 if (nsec > 1e9) { 767 nsec += -1e9; 768 in->sec += 1; 769 } 853 770 if (nsec < 0) { 854 771 in->sec += -1; … … 858 775 } 859 776 } 777 //Calculate the Julian Date from the input time in UT1 format. 860 778 double T = psTimeToJD(in); 861 779 if (T == NAN) { … … 865 783 } 866 784 T += -2451545.0; 785 //Formula for theta comes directly from the ADD. Create output psSphereRot from theta. 867 786 double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T); 868 787 psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0); … … 1003 922 static double DMOD(double x, double y) 1004 923 { 924 //Internal function for calculating the remainder of a double quotient. 925 //used often in the algorithm for psEOC_PolarTideCorr which is the Ray model of 926 //Simon et. al. from its fortran implementation. 1005 927 double value = x - y * trunc(x/y); 1006 928 return value; … … 1011 933 // Check for null parameter 1012 934 PS_ASSERT_PTR_NON_NULL(time, NULL); 1013 psEarthPole *out = psEarthPoleAlloc();1014 1015 935 // Convert psTime to MJD 1016 936 double MJD = psTimeToMJD(time); … … 1020 940 return NULL; 1021 941 } 1022 1023 // Calculate number of Julian centuries since 2000 1024 double RJD = MJD; 1025 1026 //Formula comes from fortran reference 1027 //DMOD in fortran ref. = double remainder -> x - y * trunc(x/y) 942 psEarthPole *out = psEarthPoleAlloc(); 943 944 //Formula comes from fortran reference of the Ray model of Simon et. al. 1028 945 double T, L, LPRIME, CAPF, CAPD, OMEGA, THETA, CORX, CORY, CORZ; 1029 946 double ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8; 1030 947 double T2, T3, T4; 1031 T = (RJD - 51544.5) / 36525.0; 948 // Calculate number of Julian centuries since 2000 949 T = (MJD - 51544.5) / 36525.0; 1032 950 T2 = T*T; 1033 951 T3 = T*T*T; … … 1086 1004 CORX = SEC_TO_RAD(CORX); 1087 1005 CORY = SEC_TO_RAD(CORY); 1088 // CORZ = SEC_TO_RAD(CORZ);1089 1006 1090 1007 out->x = CORX; … … 1099 1016 // Check for null parameter 1100 1017 PS_ASSERT_PTR_NON_NULL(time, NULL); 1101 /* if (time->type == PS_TIME_UT1) {1102 psError(PS_ERR_BAD_PARAMETER_VALUE, true,1103 "Invalid time input. Time cannot be of type UT1.\n");1104 return NULL;1105 }1106 */1107 1018 // Convert psTime to MJD 1108 1019 double MJD = psTimeToMJD(time); … … 1120 1031 double t4 = t*t*t*t; 1121 1032 1033 // The following formulae are from the ADD (& s5.8 of IERS Technical Note 32): 1122 1034 double F[5]; 1123 1035 // Mean Anomaly of the Moon … … 1135 1047 SEC_TO_RAD(0.00001149)*t4; 1136 1048 1137 // L â Omega 1049 // L â Omega (L = Mean Longitude of the Moon, Omega = F4) 1138 1050 F[2] = DEG_TO_RAD(93.27209062) + 1139 1051 SEC_TO_RAD(1739527262.8478)*t - … … 1252 1164 double X = 0.0; 1253 1165 double Y = 0.0; 1254 // double arg = 0.0;1255 //This is from eqn 131 in the ADD - Note: pj_tj isn't included the first time.1256 //XXX: The xp_sin, yp_cos, etc. may need to be multiplied by pow(t,i) here? adding now...1257 // double tj = 0.0;1258 1259 // calculate the polynomial portion first - the pj * t^j (poly coeff's)1260 // X = psPolynomial1DEval(xPoly,t);1261 // Y = psPolynomial1DEval(yPoly,t);1262 // X = SEC_TO_RAD(X * 1e-6);1263 // Y = SEC_TO_RAD(Y * 1e-6);1264 /* for (int i = 0; i < 10; i++) {1265 double arg = 0.0;1266 double as = 0.0;1267 double ac = 0.0;1268 arg = w_l[i]*F[0] + w_l_p[i]*F[1] + w_F[i]*F[2] + w_D[i]*F[3] + w_Omega[i]*F[4];1269 tj = 1.0;1270 as = xp_sin[i] * 1e-6;1271 ac = xp_cos[i] * 1e-6;1272 X += (as*tj*sin(arg) + ac*cos(arg)) * tj;1273 as = yp_sin[i] * 1e-6;1274 ac = yp_cos[i] * 1e-6;1275 Y += (as*tj*sin(arg) + ac*cos(arg)) * tj;1276 }1277 */1278 1166 1279 1167 //Implementation adapted from PM_GRAVI in interp.f from hpiers.obspm.fr/eop-pc/models/interp.f … … 1306 1194 ag = RAD_TO_SEC(ag); 1307 1195 ag = DMOD(ag, 2.0*M_PI); 1308 // ag = SEC_TO_RAD(ag);1309 1196 X += xp_sin[j] * SEC_TO_RAD(sin(ag)) + xp_cos[j] * SEC_TO_RAD(cos(ag)); 1310 1197 Y += yp_sin[j] * SEC_TO_RAD(sin(ag)) + yp_cos[j] * SEC_TO_RAD(cos(ag)); 1311 // X += xp_sin[j] * sin(ag) + xp_cos[j] * cos(ag);1312 // Y += yp_sin[j] * sin(ag) + yp_cos[j] * cos(ag);1313 1198 } 1314 1199 … … 1316 1201 pole->x = X; 1317 1202 pole->y = Y; 1203 //The value of s is simply: s = -4.7e-5 * t as specified by the ADD and IERS 32. 1318 1204 pole->s = -SEC_TO_RAD(4.7e-5) * t; 1319 1205 … … 1323 1209 psSphereRot* psSphereRot_ITRStoTEO(const psEarthPole* motion) 1324 1210 { 1211 // Check for null parameter 1325 1212 PS_ASSERT_PTR_NON_NULL(motion,NULL); 1326 1213 double A[3][3]; … … 1333 1220 s = -s; 1334 1221 1335 1336 //Setup Rotation Matrix for transformation (x,y,z rotation) 1337 //XXX: May need to be (z,y,x as in Mathworld?) 1338 /* A[0][0] = cos(motion->x)*cos(-motion->s); 1339 A[0][1] = sin(motion->y)*sin(motion->x)*cos(-motion->s) + cos(motion->y)*sin(-motion->s); 1340 A[0][2] = -cos(motion->y)*sin(motion->x)*cos(-motion->s) + sin(motion->y)*sin(-motion->s); 1341 A[1][0] = -cos(motion->x)*sin(-motion->s); 1342 A[1][1] = -sin(motion->y)*sin(motion->x)*sin(-motion->s) + cos(motion->y)*cos(-motion->s); 1343 A[1][2] = cos(motion->y)*sin(motion->x)*sin(-motion->s) + sin(motion->y)*cos(-motion->s); 1344 A[2][0] = sin(motion->x); 1345 A[2][1] = -sin(motion->y)*cos(motion->x); 1346 A[2][2] = cos(motion->y)*cos(motion->x); 1347 */ 1348 /* 1349 A[0][0] = cos(motion->x)*cos(-motion->s); 1350 A[1][0] = sin(motion->y)*sin(motion->x)*cos(-motion->s) + cos(motion->y)*sin(-motion->s); 1351 A[2][0] = -cos(motion->y)*sin(motion->x)*cos(-motion->s) + sin(motion->y)*sin(-motion->s); 1352 A[0][1] = -cos(motion->x)*sin(-motion->s); 1353 A[1][1] = -sin(motion->y)*sin(motion->x)*sin(-motion->s) + cos(motion->y)*cos(-motion->s); 1354 A[2][1] = cos(motion->y)*sin(motion->x)*sin(-motion->s) + sin(motion->y)*cos(-motion->s); 1355 A[0][2] = sin(motion->x); 1356 A[1][2] = -sin(motion->y)*cos(motion->x); 1357 A[2][2] = cos(motion->y)*cos(motion->x); 1358 */ 1359 /* 1360 A[0][0] = cos(s)*cos(x); 1361 A[0][1] = sin(s)*sin(y) + cos(s)*sin(x)*sin(y); 1362 A[0][2] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1363 A[1][0] = -sin(s)*cos(x); 1364 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1365 A[1][2] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1366 A[2][0] = sin(x); 1367 A[2][1] = -cos(x)*sin(y); 1368 A[2][2] = cos(x)*cos(y); 1369 */ 1370 /* 1371 A[0][0] = cos(s)*cos(x); 1372 A[1][0] = sin(s)*sin(y) + cos(s)*sin(x)*sin(y); 1373 A[2][0] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1374 A[0][1] = -sin(s)*cos(x); 1375 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1376 A[2][1] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1377 A[0][2] = sin(x); 1378 A[1][2] = -cos(x)*sin(y); 1379 A[2][2] = cos(x)*cos(y); 1380 */ 1381 1382 /* 1383 psSphereRot r,p,t; 1384 1385 r.q0=sin(y/2.0); 1386 r.q1=0; 1387 r.q2=0; 1388 r.q3=cos(y/2.0); 1389 1390 p.q0=0; 1391 p.q1=sin(x/2.0); 1392 p.q2=0; 1393 p.q3=cos(x/2.0); 1394 1395 t.q0=0; 1396 t.q1=0; 1397 t.q2=sin(s/2.0); 1398 t.q3=cos(s/2.0); 1399 1400 // calculate t*s*r. 1401 psSphereRot* temp = psSphereRotCombine(NULL,&t,&p); 1402 out = psSphereRotCombine(NULL, temp, &r); 1403 psFree(temp); 1404 1405 return out; 1406 */ 1407 1408 //Newest trial - mult. y matrix * x * z 1409 1222 //Setup Rotation matrix. Rotation is constructed by rotation about the X-axis by y, 1223 // about the Y-axis by x, and about the Z-axis by s' (where s' = -s). 1410 1224 A[0][0] = cos(x)*cos(s); 1411 1225 A[1][0] = cos(x)*sin(s); … … 1418 1232 A[2][2] = cos(x)*cos(y); 1419 1233 1420 /*1421 A[0][0] = cos(x)*cos(s);1422 A[0][1] = cos(x)*sin(s);1423 A[0][2] = -sin(x);1424 A[1][0] = sin(x)*sin(y)*cos(s) - cos(y)*sin(s);1425 A[1][1] = sin(x)*sin(y)*sin(s) + cos(y)*cos(s);1426 A[1][2] = cos(x)*sin(y);1427 A[2][0] = sin(x)*cos(y)*cos(s) + sin(y)*sin(s);1428 A[2][1] = sin(x)*cos(y)*sin(s) - sin(y)*cos(s);1429 A[2][2] = cos(x)*cos(y);1430 */1431 //New trial - mult z * y * x1432 /* A[0][0] = cos(s)*cos(x);1433 A[1][0] = sin(s)*cos(y) + cos(s)*sin(x)*sin(y);1434 A[2][0] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y);1435 A[0][1] = -sin(s)*cos(x);1436 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y);1437 A[2][1] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y);1438 A[0][2] = sin(x);1439 A[1][2] = -cos(x)*sin(y);1440 A[2][2] = cos(x)*cos(y);1441 */1442 /*1443 A[0][0] = cos(s)*cos(x);1444 A[0][1] = sin(s)*cos(y) + cos(s)*sin(x)*sin(y);1445 A[0][2] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y);1446 A[1][0] = -sin(s)*cos(x);1447 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y);1448 A[1][2] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y);1449 A[2][0] = sin(x);1450 A[2][1] = -cos(x)*sin(y);1451 A[2][2] = cos(x)*cos(y);1452 */1453 1454 1234 //Convert rotation matrix to quaternions 1455 1235 out = rotMatrix_To_Quat(A); … … 1484 1264 psTime *from = NULL; 1485 1265 psTime *to = NULL; 1266 if (fromMJD > toMJD) { 1267 psWarning("From time is later than to time in psSpherePrecess.\n"); 1268 } 1486 1269 1487 1270 if (mode == PS_PRECESS_ROUGH) { … … 1525 1308 to = p_psTimeCopy(toTime); 1526 1309 } 1527 1310 //Calculate the earthpoles and quaternions corresponding to each time (from, to). 1311 //Combine the quaternions to produce the output psSphereRot. 1528 1312 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1529 1313 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); … … 1557 1341 to = p_psTimeCopy(toTime); 1558 1342 } 1559 1343 //Calculate the earthpoles and quaternions corresponding to each time (from, to). 1344 //Add in the precession corrections from IERS bulletin A. 1345 //Combine the quaternions to produce the output psSphereRot. 1560 1346 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1561 1347 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_A); 1562 1348 fromEP->x += fromCorr->x; 1563 1349 fromEP->y += fromCorr->y; 1564 fromEP->s += fromCorr->s;1565 1350 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1566 1351 psEarthPole *toEP = psEOC_PrecessionModel(to); … … 1568 1353 toEP->x += toCorr->x; 1569 1354 toEP->y += toCorr->y; 1570 toEP->s += toCorr->s;1571 1355 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1572 1356 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); … … 1600 1384 } 1601 1385 1386 //Calculate the earthpoles and quaternions corresponding to each time (from, to). 1387 //Add in the precession corrections from IERS bulletin B. 1388 //Combine the quaternions to produce the output psSphereRot. 1602 1389 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1603 1390 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_B); 1604 1391 fromEP->x += fromCorr->x; 1605 1392 fromEP->y += fromCorr->y; 1606 fromEP->s += fromCorr->s;1607 1393 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1608 1394 psEarthPole *toEP = psEOC_PrecessionModel(to); … … 1610 1396 toEP->x += toCorr->x; 1611 1397 toEP->y += toCorr->y; 1612 toEP->s += toCorr->s;1613 1398 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1614 1399 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); … … 1625 1410 return out; 1626 1411 } 1627 // Apply transform to coordinates 1628 // psSphere *out = psSphereRotApply(NULL, tmpST, coords); 1629 // if (out->r < -0.0001) { 1630 // out->r += 2.0 * M_PI; 1631 // } 1632 } 1412 } -
trunk/psLib/src/astro/psEarthOrientation.h
r6184 r6425 9 9 * @author Robert Daniel DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-0 1-23 20:04:31$11 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-02-14 00:09:27 $ 13 13 * 14 14 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 131 131 /** Calculates the rotation of the Earth about the CIP. 132 132 * 133 * @return psSphereRot*: sphereical rotation 133 * If tidalCorr is non-NULL, use the S-component to provide tidal corrections to the 134 * UT1 time. If tidalCorr is NULL, no corrections are made & this step is skipped. 135 * 136 * @return psSphereRot*: spherical rotation of the Earth about the CIP. 134 137 */ 135 138 psSphereRot *psSphereRot_TEOtoCEO( … … 187 190 */ 188 191 psSphereRot* psSpherePrecess( 189 // psSphere *coords, ///< coordinates (modified in-place)190 192 const psTime *fromTime, ///< equinox of coords input 191 193 const psTime *toTime, ///< equinox of coords output -
trunk/psLib/src/astro/psSphereOps.h
r6187 r6425 8 8 * @author David Robbins, MHPCC 9 9 * 10 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 1-23 23:52:15$10 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-02-14 00:09:27 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 /// @{ 21 21 22 //#include "psCoord.h"23 22 #include "psTime.h" 24 23 -
trunk/psLib/src/sys/psMemory.c
r6419 r6425 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.6 8$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-02-1 0 02:44:46$10 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-02-14 00:09:27 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1076 1076 bool out = safeThreads; 1077 1077 safeThreads = safe; 1078 if ( out != p_psListThreadSafety(safe) ) {1079 psWarning("Thread safety setting in psMemory didn't match that of psList.\n");1080 }1081 1078 return out; 1082 1079 } -
trunk/psLib/src/types/psList.c
r6419 r6425 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-02-1 0 02:44:46$8 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-02-14 00:09:27 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 33 33 static psBool listIteratorRemove(psListIterator* iterator); 34 34 35 //private boolean for enabling/disabling thread safety. Default = enabled.36 static bool safeThreads = true;37 38 35 static void listFree(psList* list) 39 36 { 40 37 if (list == NULL) { 41 38 return; 42 }43 44 if (safeThreads) {45 pthread_mutex_lock(&list->p_lock);46 // pthread_mutex_lock(&p_lock);47 39 } 48 40 … … 69 61 ptr = next; 70 62 } 71 72 if (safeThreads) {73 pthread_mutex_unlock(&list->p_lock);74 pthread_mutex_destroy(&list->p_lock);75 // pthread_mutex_unlock(&p_lock);76 // pthread_mutex_destroy(&p_lock);77 } else {78 safeThreads = true;79 }80 63 } 81 64 … … 110 93 int index = iterator->index; 111 94 112 if (safeThreads) {113 pthread_mutex_lock(&list->p_lock);114 // pthread_mutex_lock(&p_lock);115 }116 95 if (elem == list->head) { // head of list? 117 96 list->head = elem->next; … … 138 117 list->n--; 139 118 140 if (safeThreads) {141 pthread_mutex_unlock(&list->p_lock);142 // pthread_mutex_unlock(&p_lock);143 }144 145 119 // OK, delete orphaned list element and its data 146 120 psFree(elem->data); … … 164 138 psListIteratorAlloc(list,PS_LIST_HEAD,true); 165 139 166 if (safeThreads) {167 pthread_mutex_init(&(list->p_lock), NULL);168 // pthread_mutex_init(&p_lock, NULL);169 }170 171 140 if (data != NULL) { 172 141 psListAdd(list, PS_LIST_TAIL, data); … … 179 148 { 180 149 return ( psMemGetDeallocator(ptr) == (psFreeFunc)listFree ); 181 }182 183 bool p_psListThreadSafety(bool safe)184 {185 bool out = safeThreads;186 safeThreads = safe;187 return out;188 150 } 189 151 … … 347 309 348 310 psListElem* elem = psAlloc(sizeof(psListElem)); 349 350 if (safeThreads) {351 pthread_mutex_lock(&list->p_lock);352 // pthread_mutex_lock(&p_lock);353 }354 311 355 312 // set the new list element's attributes … … 387 344 } 388 345 389 if (safeThreads) {390 pthread_mutex_unlock(&list->p_lock);391 // pthread_mutex_unlock(&p_lock);392 }393 394 346 return true; 395 347 } … … 426 378 427 379 psListElem* elem = psAlloc(sizeof(psListElem)); 428 429 if (safeThreads) {430 pthread_mutex_lock(&list->p_lock);431 // pthread_mutex_lock(&p_lock);432 }433 380 434 381 // set the new list element's attributes … … 466 413 } 467 414 468 if (safeThreads) {469 pthread_mutex_unlock(&list->p_lock);470 // pthread_mutex_unlock(&p_lock);471 }472 473 415 return true; 474 416 } -
trunk/psLib/src/types/psList.h
r6419 r6425 7 7 * @ingroup LinkedList 8 8 * 9 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-02-1 0 02:44:46$9 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-02-14 00:09:27 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 59 59 ///< used internally to improve performance when using indexed access, all 60 60 ///< others are user-level iterators created by psListIteratorAlloc. 61 pthread_mutex_t p_lock; ///< mutex to lock a node during changes62 61 void *lock; ///< Optional lock for thread safety 63 62 } … … 94 93 ; 95 94 96 /** Private function used by psMemThreadSafety to activate/deactivate thread safety.97 *98 * @return bool: The previous value of the thread safety.99 */100 bool p_psListThreadSafety(101 bool safe ///< current value of thread safety to set102 );103 104 95 /** Creates a psList linked list object. 105 96 *
Note:
See TracChangeset
for help on using the changeset viewer.
