Changeset 5771
- Timestamp:
- Dec 12, 2005, 3:31:54 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 2 edited
-
src/astro/psEarthOrientation.c (modified) (8 diffs)
-
test/astro/tst_psEarthOrientation.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5749 r5771 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-12- 08 02:49:04 $10 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-12-13 01:31:54 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 432 432 double S = psPolynomial1DEval(sPoly,t); 433 433 434 X = SEC_TO_RAD(X * 1e-6); 435 Y = SEC_TO_RAD(Y * 1e-6); 436 S = SEC_TO_RAD(S * 1e-6); 437 438 434 439 // now calculate the non-poly portion from the tables 435 440 … … 448 453 double as = cols[1][lcv]; 449 454 double ac = cols[2][lcv]; 450 451 X += as*tj*sin(arg) + ac*tj*cos(arg); 455 // printf("as-x, ac-x, = %.13g, %.13g\n", as, ac); 456 as = SEC_TO_RAD(as) * 1e-6; 457 ac = SEC_TO_RAD(ac) * 1e-6; 458 // X += as*tj*sin(arg) + ac*tj*cos(arg); 459 X += (as*tj*sin(arg) + ac*cos(arg)) * tj; 452 460 } 453 461 … … 465 473 double as = cols[1][lcv]; 466 474 double ac = cols[2][lcv]; 467 468 Y += as*tj*sin(arg) + ac*tj*cos(arg); 475 as = SEC_TO_RAD(as) * 1e-6; 476 ac = SEC_TO_RAD(ac) * 1e-6; 477 478 // Y += as*tj*sin(arg) + ac*tj*cos(arg); 479 Y += (as*tj*sin(arg) + ac*cos(arg)) * tj; 469 480 } 470 481 … … 482 493 double as = cols[1][lcv]; 483 494 double ac = cols[2][lcv]; 484 485 S += as*tj*sin(arg) + ac*tj*cos(arg); 495 as = SEC_TO_RAD(as) * 1e-6; 496 ac = SEC_TO_RAD(ac) * 1e-6; 497 498 // S += as*tj*sin(arg) + ac*tj*cos(arg); 499 S += (as*tj*sin(arg) + ac*cos(arg)) * tj; 486 500 } 487 501 … … 700 714 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y); 701 715 */ 716 702 717 A[0][0] = (1.0 - a*pole->x*pole->x)*cos(pole->s) - a*pole->x*pole->y*sin(pole->s); 703 718 A[1][0] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s); … … 709 724 A[1][2] = -pole->y; 710 725 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y); 726 711 727 double x, y, s; 712 728 x = pole->x; … … 1010 1026 psSphereRot *out = NULL; 1011 1027 1028 double x,y,s; 1029 x = motion->x; 1030 y = motion->y; 1031 s = motion->s; 1032 1033 1012 1034 //Setup Rotation Matrix for transformation (x,y,z rotation) 1013 1035 //XXX: May need to be (z,y,x as in Mathworld?) 1014 A[0][0] = cos(motion->x)*cos(-motion->s); 1015 A[0][1] = sin(motion->y)*sin(motion->x)*cos(-motion->s) + cos(motion->y)*sin(-motion->s); 1016 A[0][2] = -cos(motion->y)*sin(motion->x)*cos(-motion->s) + sin(motion->y)*sin(-motion->s); 1017 A[1][0] = -cos(motion->x)*sin(-motion->s); 1018 A[1][1] = -sin(motion->y)*sin(motion->x)*sin(-motion->s) + cos(motion->y)*cos(-motion->s); 1019 A[1][2] = cos(motion->y)*sin(motion->x)*sin(-motion->s) + sin(motion->y)*cos(-motion->s); 1020 A[2][0] = sin(motion->x); 1021 A[2][1] = -sin(motion->y)*cos(motion->x); 1022 A[2][2] = cos(motion->y)*cos(motion->x); 1036 /* A[0][0] = cos(motion->x)*cos(-motion->s); 1037 A[0][1] = sin(motion->y)*sin(motion->x)*cos(-motion->s) + cos(motion->y)*sin(-motion->s); 1038 A[0][2] = -cos(motion->y)*sin(motion->x)*cos(-motion->s) + sin(motion->y)*sin(-motion->s); 1039 A[1][0] = -cos(motion->x)*sin(-motion->s); 1040 A[1][1] = -sin(motion->y)*sin(motion->x)*sin(-motion->s) + cos(motion->y)*cos(-motion->s); 1041 A[1][2] = cos(motion->y)*sin(motion->x)*sin(-motion->s) + sin(motion->y)*cos(-motion->s); 1042 A[2][0] = sin(motion->x); 1043 A[2][1] = -sin(motion->y)*cos(motion->x); 1044 A[2][2] = cos(motion->y)*cos(motion->x); 1045 */ 1046 /* 1047 A[0][0] = cos(motion->x)*cos(-motion->s); 1048 A[1][0] = sin(motion->y)*sin(motion->x)*cos(-motion->s) + cos(motion->y)*sin(-motion->s); 1049 A[2][0] = -cos(motion->y)*sin(motion->x)*cos(-motion->s) + sin(motion->y)*sin(-motion->s); 1050 A[0][1] = -cos(motion->x)*sin(-motion->s); 1051 A[1][1] = -sin(motion->y)*sin(motion->x)*sin(-motion->s) + cos(motion->y)*cos(-motion->s); 1052 A[2][1] = cos(motion->y)*sin(motion->x)*sin(-motion->s) + sin(motion->y)*cos(-motion->s); 1053 A[0][2] = sin(motion->x); 1054 A[1][2] = -sin(motion->y)*cos(motion->x); 1055 A[2][2] = cos(motion->y)*cos(motion->x); 1056 */ 1057 /* 1058 A[0][0] = cos(s)*cos(x); 1059 A[0][1] = sin(s)*sin(y) + cos(s)*sin(x)*sin(y); 1060 A[0][2] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1061 A[1][0] = -sin(s)*cos(x); 1062 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1063 A[1][2] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1064 A[2][0] = sin(x); 1065 A[2][1] = -cos(x)*sin(y); 1066 A[2][2] = cos(x)*cos(y); 1067 */ 1068 /* 1069 A[0][0] = cos(s)*cos(x); 1070 A[1][0] = sin(s)*sin(y) + cos(s)*sin(x)*sin(y); 1071 A[2][0] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1072 A[0][1] = -sin(s)*cos(x); 1073 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1074 A[2][1] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1075 A[0][2] = sin(x); 1076 A[1][2] = -cos(x)*sin(y); 1077 A[2][2] = cos(x)*cos(y); 1078 */ 1079 1080 /* 1081 psSphereRot r,s,t; 1082 1083 // directly from ADD -- there must be a better way?! 1084 r.q0=sin(motion->y/2.0); 1085 r.q1=0; 1086 r.q2=0; 1087 r.q3=cos(motion->y/2.0); 1088 1089 s.q0=0; 1090 s.q1=sin(motion->x/2.0); 1091 s.q2=0; 1092 s.q3=cos(motion->x/2.0); 1093 1094 t.q0=0; 1095 t.q1=0; 1096 t.q2=sin(-motion->s/2.0); 1097 t.q3=cos(-motion->s/2.0); 1098 1099 // calculate t*s*r. 1100 psSphereRot* temp = psSphereRotCombine(NULL,&t,&s); 1101 out = psSphereRotCombine(NULL, temp, &r); 1102 psFree(temp); 1103 1104 return out; 1105 */ 1106 1107 s = -s; 1108 //Newest trial - mult. y matrix * x * z 1109 /* A[0][0] = cos(x)*cos(s); 1110 A[1][0] = cos(x)*sin(s); 1111 A[2][0] = -sin(x); 1112 A[0][1] = sin(x)*sin(y)*cos(s) - cos(y)*sin(s); 1113 A[1][1] = sin(x)*sin(y)*sin(s) + cos(y)*cos(s); 1114 A[2][1] = cos(x)*sin(y); 1115 A[0][2] = sin(x)*cos(y)*cos(s) + sin(y)*sin(s); 1116 A[1][2] = sin(x)*cos(y)*sin(s) - sin(y)*cos(s); 1117 A[2][2] = cos(x)*cos(y); 1118 */ 1119 /* A[0][0] = cos(x)*cos(s); 1120 A[0][1] = cos(x)*sin(s); 1121 A[0][2] = -sin(x); 1122 A[1][0] = sin(x)*sin(y)*cos(s) - cos(y)*sin(s); 1123 A[1][1] = sin(x)*sin(y)*sin(s) + cos(y)*cos(s); 1124 A[1][2] = cos(x)*sin(y); 1125 A[2][0] = sin(x)*cos(y)*cos(s) + sin(y)*sin(s); 1126 A[2][1] = sin(x)*cos(y)*sin(s) - sin(y)*cos(s); 1127 A[2][2] = cos(x)*cos(y); 1128 */ 1129 //New trial - mult z * y * x 1130 /* A[0][0] = cos(s)*cos(x); 1131 A[1][0] = sin(s)*cos(y) + cos(s)*sin(x)*sin(y); 1132 A[2][0] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1133 A[0][1] = -sin(s)*cos(x); 1134 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1135 A[2][1] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1136 A[0][2] = sin(x); 1137 A[1][2] = -cos(x)*sin(y); 1138 A[2][2] = cos(x)*cos(y); 1139 */ 1140 A[0][0] = cos(s)*cos(x); 1141 A[0][1] = sin(s)*cos(y) + cos(s)*sin(x)*sin(y); 1142 A[0][2] = sin(s)*sin(y) - cos(s)*sin(x)*cos(y); 1143 A[1][0] = -sin(s)*cos(x); 1144 A[1][1] = cos(s)*cos(y) - sin(s)*sin(x)*sin(y); 1145 A[1][2] = cos(s)*sin(y) + sin(s)*sin(x)*cos(y); 1146 A[2][0] = sin(x); 1147 A[2][1] = -cos(x)*sin(y); 1148 A[2][2] = cos(x)*cos(y); 1149 1023 1150 1024 1151 //Convert rotation matrix to quaternions 1025 1152 out = rotMatrix_To_Quat(A); 1153 1154 // out = psSphereRotAlloc(motion->y, motion->x, motion->s); 1155 1156 // out->q0 = SEC_TO_RAD(out->q0); 1157 // out->q1 = SEC_TO_RAD(out->q1); 1158 // out->q2 = SEC_TO_RAD(out->q2) + (out->q0+out->q1/2.0); 1159 // out->q3 = sqrt(1.0 - (out->q0*out->q0 + out->q1*out->q1 + out->q2*out->q2) ); 1026 1160 /* double diag_sum[3]; 1027 1161 int maxi; -
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5749 r5771 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-12- 08 02:49:04 $7 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-12-13 01:31:54 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 344 344 yy = -0.0287618408203125; 345 345 ss = 0.0; 346 xx = SEC_TO_RAD(xx) * 1e-6; 347 yy = SEC_TO_RAD(yy) * 1e-6; 346 348 if ( fabs(pcorr->x - xx) > DBL_EPSILON || fabs(pcorr->y - yy) > DBL_EPSILON 347 349 || fabs(pcorr->s - ss) > DBL_EPSILON) { … … 599 601 // in->y += -0.0287618408203125; 600 602 // in->s += 0.0; 603 // in->x += 3.05224300720406e-7; 604 // in->y += -1.39441339235822e-7; 605 in->s += 0.0; 606 601 607 double q0,q1,q2,q3; 602 608 q0 = -1.1984522406756289e-5; … … 619 625 } 620 626 621 // psCube *tempCube = psCubeAlloc(); 622 // tempCube->x = -0.35963388069046304; 623 // tempCube->y = 0.5555192509816625; 624 // tempCube->z = 0.749078321908413; 625 // obj = psCubeToSphere(tempCube); 626 // psFree(tempCube); 627 obj = psSphereAlloc(); 628 obj->r = objR; 629 obj->d = objD; 627 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON || 628 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) { 629 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 630 "psSphereRot_CEOtoGCRS failed to return expected values.\n"); 631 printf("\n Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 632 rot->q0, rot->q1, rot->q2, rot->q3); 633 printf(" Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 634 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1), 635 (rot->q2-q2), (rot->q3-q3) ); 636 printf(" abs difference: %.13g, %.13g, %.13g, %.13g \n\n", (rot->q0+q0), (rot->q1+q1), 637 (rot->q2+q2), (rot->q3+q3) ); 638 // return 3; 639 } 640 641 642 psCube *tempCube = psCubeAlloc(); 643 tempCube->x = -0.35963388069046304; 644 tempCube->y = 0.5555192509816625; 645 tempCube->z = 0.7497078321908413; 646 obj = psCubeToSphere(tempCube); 647 psFree(tempCube); 648 // obj = psSphereAlloc(); 649 // obj->r = objR; 650 // obj->d = objD; 630 651 psSphereRot *precessionNutation = psSphereRotConjugate(NULL, rot); 631 652 psSphere *result = psSphereRotApply(NULL, precessionNutation, obj); … … 639 660 printf("A difference of: %.13g, %.13g, %.13g\n\n", 640 661 (x-cube->x), (y-cube->y), (z-cube->z)); 662 663 //great sphere difference between result and expected 664 //Re = 6.38x10^6m 665 psCube *expect = psCubeAlloc(); 666 expect->x = x; 667 expect->y = y; 668 expect->z = z; 669 psSphere *expected = psCubeToSphere(expect); 670 psFree(expect); 671 double d = (6.38e6) * acos(cos(result->r)*cos(expected->r)*cos(result->d-expected->d) + sin(result->r)*sin(expected->r)); 672 printf("\n\nGreat circle difference of: %.13g \n", d); 673 674 psFree(expected); 641 675 psFree(obj); 642 676 643 677 644 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON ||645 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) {646 psError(PS_ERR_BAD_PARAMETER_VALUE, false,647 "psSphereRot_CEOtoGCRS failed to return expected values.\n");648 printf("\n Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n",649 rot->q0, rot->q1, rot->q2, rot->q3);650 printf(" Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3);651 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1),652 (rot->q2-q2), (rot->q3-q3) );653 printf(" abs difference: %.13g, %.13g, %.13g, %.13g \n\n", (rot->q0+q0), (rot->q1+q1),654 (rot->q2+q2), (rot->q3+q3) );655 return 3;656 }657 678 658 679 psSphere *test = psSphereAlloc(); … … 708 729 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 709 730 "psSphereRot_ITRStoTEO failed to return expected values.\n"); 710 printf("\n Output sphere rotation = %.13g, %.13g,%.13g,%.13g\n",731 printf("\n Output sphere rotation = %.13g, %.13g, %.13g, %.13g\n", 711 732 rot->q0, rot->q1, rot->q2, rot->q3); 712 printf(" Expected sphere rotation = %.13g, %.13g,%.13g,%.13g\n", q0,q1,q2,q3);713 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1),714 (rot->q2-q2), (rot->q3-q3) );733 printf(" Expected sphere rotation = %.13g, %.13g, %.13g, %.13g\n", q0,q1,q2,q3); 734 // printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1), 735 // (rot->q2-q2), (rot->q3-q3) ); 715 736 return 3; 716 737 }
Note:
See TracChangeset
for help on using the changeset viewer.
