Changeset 5749
- Timestamp:
- Dec 7, 2005, 4:49:04 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 2 edited
-
src/astro/psEarthOrientation.c (modified) (2 diffs)
-
test/astro/tst_psEarthOrientation.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5657 r5749 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-12-0 2 04:40:00$10 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-12-08 02:49:04 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 690 690 //XXX: Used formula for rotation matrix D from mathworld for z-axis rotation 691 691 double a = 1.0 / (1.0 + sqrt(1.0 - (pole->x*pole->x + pole->y*pole->y) ) ); 692 /* A[0][0] = (1.0 - a*pole->x*pole->x)*cos(pole->s) - a*pole->x*pole->y*sin(pole->s); 693 A[0][1] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s); 694 A[0][2] = pole->x*cos(pole->s) + pole->y*sin(pole->s); 695 A[1][0] = -(1.0 - a*pole->x*pole->x)*sin(pole->s) - a*pole->x*pole->y*cos(pole->s); 696 A[1][1] = a*pole->x*pole->y*sin(pole->s) + (1.0 - a*pole->y*pole->y)*cos(pole->s); 697 A[1][2] = -pole->x*sin(pole->s) + pole->y*cos(pole->s); 698 A[2][0] = -pole->x; 699 A[2][1] = -pole->y; 700 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y); 701 */ 692 702 A[0][0] = (1.0 - a*pole->x*pole->x)*cos(pole->s) - a*pole->x*pole->y*sin(pole->s); 693 A[ 0][1] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s);694 A[ 0][2] = pole->x*cos(pole->s) + pole->y*sin(pole->s);695 A[ 1][0] = -(1.0 - a*pole->x*pole->x)*sin(pole->s) - a*pole->x*pole->y*cos(pole->s);703 A[1][0] = -a*pole->x*pole->y*cos(pole->s) + (1.0 - a*pole->y*pole->y)*sin(pole->s); 704 A[2][0] = pole->x*cos(pole->s) + pole->y*sin(pole->s); 705 A[0][1] = -(1.0 - a*pole->x*pole->x)*sin(pole->s) - a*pole->x*pole->y*cos(pole->s); 696 706 A[1][1] = a*pole->x*pole->y*sin(pole->s) + (1.0 - a*pole->y*pole->y)*cos(pole->s); 697 A[ 1][2] = -pole->x*sin(pole->s) + pole->y*cos(pole->s);698 A[ 2][0] = -pole->x;699 A[ 2][1] = -pole->y;707 A[2][1] = -pole->x*sin(pole->s) + pole->y*cos(pole->s); 708 A[0][2] = -pole->x; 709 A[1][2] = -pole->y; 700 710 A[2][2] = 1.0 - a*(pole->x*pole->x + pole->y*pole->y); 701 711 double x, y, s; 712 x = pole->x; 713 y = pole->y; 714 s = pole->s; 715 /* A[0][0] = (1.0 - a*x*x)*cos(s) + a*x*y*sin(s); 716 A[0][1] = (1.0 - a*x*x)*sin(s) - a*x*y*cos(s); 717 A[0][2] = x; 718 A[1][0] = -a*x*y*cos(s) - (1.0 - a*y*y)*sin(s); 719 A[1][1] = -a*x*y*sin(s) + (1.0 - a*y*y)*cos(s); 720 A[1][2] = y; 721 A[2][0] = -x*cos(s) + y*sin(s); 722 A[2][1] = -x*sin(s) - y*cos(s); 723 A[2][2] = 1.0 - a * (x*x + y*y); 724 */ 725 /* A[0][0] = (1.0 - a*x*x)*cos(s) + a*x*y*sin(s); 726 A[1][0] = (1.0 - a*x*x)*sin(s) - a*x*y*cos(s); 727 A[2][0] = x; 728 A[0][1] = -a*x*y*cos(s) - (1.0 - a*y*y)*sin(s); 729 A[1][1] = -a*x*y*sin(s) + (1.0 - a*y*y)*cos(s); 730 A[2][1] = y; 731 A[0][2] = -x*cos(s) + y*sin(s); 732 A[1][2] = -x*sin(s) - y*cos(s); 733 A[2][2] = 1.0 - a * (x*x + y*y); 734 */ 702 735 out = rotMatrix_To_Quat(A); 703 736 -
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5716 r5749 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-12-0 7 02:13:40$7 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-12-08 02:49:04 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 66 66 { 67 67 if (obj == NULL) { 68 obj = psSphereAlloc(); 69 obj->r = objR; 70 obj->d = objD; 68 // obj = psSphereAlloc(); 69 // obj->r = objR; 70 // obj->d = objD; 71 psCube *tempCube = psCubeAlloc(); 72 tempCube->x = -0.3598480726985338; 73 tempCube->y = 0.5555012823608123; 74 tempCube->z = 0.7496183628158023; 75 obj = psCubeToSphere(tempCube); 76 psFree(tempCube); 71 77 } 72 78 } … … 544 550 return 2; 545 551 } 546 printf("\nOutput sphere rotation = %.13g, %.13g, %.13g, %.13g\n\n",547 teoceo->q0, teoceo->q1, teoceo->q2, teoceo->q3);548 552 549 553 objSetup(); 550 554 psSphereRot *earthRot = psSphereRotConjugate(NULL, teoceo); 551 555 psSphere *result = psSphereRotApply(NULL, earthRot, obj); 552 // psCube *cube = psSphereToCube(obj);553 556 psCube *cube = psSphereToCube(result); 554 555 557 556 558 double x, y, z; … … 558 560 y = -0.6616523084626379; 559 561 z = 0.7496183628158023; 560 if ( fabs(x-cube->x) > DBL_EPSILON || fabs(y-cube->y) > DBL_EPSILON ||561 fabs(z-cube->z) > DBL_EPSILON) {562 if ( fabs(x-cube->x) > FLT_EPSILON || fabs(y-cube->y) > FLT_EPSILON || 563 fabs(z-cube->z) > FLT_EPSILON) { 562 564 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 563 565 "psSphereRot_TEOtoCEO returned incorrect values.\n"); … … 570 572 } 571 573 // psFree(now); 574 psFree(rot); 575 psFree(empty); 572 576 psFree(result); 573 577 psFree(obj); … … 615 619 } 616 620 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; 630 psSphereRot *precessionNutation = psSphereRotConjugate(NULL, rot); 631 psSphere *result = psSphereRotApply(NULL, precessionNutation, obj); 632 psCube *cube = psSphereToCube(result); 633 double x, y, z; 634 x = -0.3598480726985338; 635 y = 0.5555012823608123; 636 z = 0.7496183628158023; 637 printf("\nOutput cube = x,y,z = %.13g, %.13g, %.13g\n", cube->x, cube->y, cube->z); 638 printf("Expected cube = x,y,z = %.13g, %.13g, %.13g\n", x, y, z); 639 printf("A difference of: %.13g, %.13g, %.13g\n\n", 640 (x-cube->x), (y-cube->y), (z-cube->z)); 641 psFree(obj); 642 643 617 644 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON || 618 645 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) { … … 635 662 printf("\n Sphere -test- has values r,d = %.8g, %.8g \n", test->r, test->d); 636 663 664 psFree(precessionNutation); 665 psFree(result); 666 psFree(cube); 667 637 668 psFree(test); 638 669 psFree(rot);
Note:
See TracChangeset
for help on using the changeset viewer.
