Changeset 5444
- Timestamp:
- Oct 24, 2005, 2:38:00 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 3 edited
-
src/astro/psSphereOps.c (modified) (2 diffs)
-
src/astro/psSphereOps.h (modified) (5 diffs)
-
test/astro/tst_psSphereOps.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psSphereOps.c
r5437 r5444 8 8 * @author Dave Robbins, MHPCC 9 9 * 10 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-10-2 1 02:14:02$10 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-25 00:38:00 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 135 135 0.0); 136 136 137 /* psSphereRot *test = psSphereRotICRSToGalactic(); 138 if (fabs(coord->d-DEG_TO_RAD(27.1283)) < 0.0001 && transform->q0 == test->q0 && 139 transform->q1 == test->q1 && transform->q2 == test->q2 && transform->q3 == test->q3){ 140 printf("\ncoordquat = %lf,%lf,%lf,%lf\n", coordQuat->q0, coordQuat->q1, coordQuat->q2, 141 coordQuat->q3); 142 // coordQuat->q1 += -1.0; 143 test->q3 = - test->q3; 144 *(psSphereRot**)&transform = test; 145 } 146 psFree(test); 147 */ 137 148 // Inserted by PAP 138 149 psSphereRot *conjugate = psSphereRotConjugate(NULL, transform); -
trunk/psLib/src/astro/psSphereOps.h
r5437 r5444 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-10-2 1 02:14:02$9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-10-25 00:38:00 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 45 45 */ 46 46 typedef enum { 47 PS_SPHERICAL, ///< offset corresponds to an angular offset48 PS_LINEAR ///< offset corresponds to a linear offset47 PS_SPHERICAL, ///< offset corresponds to an angular offset 48 PS_LINEAR ///< offset corresponds to a linear offset 49 49 } psSphereOffsetMode; 50 50 … … 55 55 */ 56 56 typedef enum { 57 PS_ARCSEC, ///< Arcseconds58 PS_ARCMIN, ///< Arcminutes59 PS_DEGREE, ///< Degrees60 PS_RADIAN ///< Radians57 PS_ARCSEC, ///< Arcseconds 58 PS_ARCMIN, ///< Arcminutes 59 PS_DEGREE, ///< Degrees 60 PS_RADIAN ///< Radians 61 61 } psSphereOffsetUnit; 62 62 … … 68 68 69 69 psSphereRot* psSphereRotAlloc( 70 double alphaP, ///< north pole latitude71 double deltaP, ///< north pole longitude72 double phiP ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).70 double alphaP, ///< north pole latitude 71 double deltaP, ///< north pole longitude 72 double phiP ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares). 73 73 ); 74 74 … … 145 145 double deltaP, ///< north pole longitude 146 146 double phiP ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares). 147 );148 149 /** Converts a psCube to a psSphere150 *151 * @return psSphere* New psSphere that is equivalent to the input psCube152 *153 */154 psSphere* psCubeToSphere(155 const psCube* cube ///< a cubic coordinate to convert156 );157 158 /** Converts a psSphere to a psCube159 *160 * @return psCube* New psCube that is equivalent to the input psSphere161 *162 */163 psCube* psSphereToCube(164 const psSphere* sphere ///< a spherical coordinate to convert165 147 ); 166 148 -
trunk/psLib/test/astro/tst_psSphereOps.c
r5437 r5444 6 6 * @author d-Rob, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10-2 1 02:14:02$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-25 00:38:00 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 19 19 static psS32 testSphereRotApplyCelestial(void); 20 20 static psS32 testSphereRotPrecess(void); 21 static psS32 testSphereToFromCube(void);22 21 static psS32 testSphereOffset(void); 23 22 … … 28 27 {testSphereRotApplyCelestial, 822, "psSphereRotApplyCel()", 0, false}, 29 28 {testSphereRotPrecess, 823, "psSphereRotPrecess()", 0, false}, 30 {testSphereToFromCube, 824, "testSphereToFromCube()", 0, false},31 29 {testSphereOffset, 825, "testSphereOffset()", 0, false}, 32 30 {NULL} … … 73 71 double q3 = cos(a3)*cos(DELTA_P/2); 74 72 75 // printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);76 // printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);77 73 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 78 74 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0); … … 117 113 } 118 114 119 // printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);120 // printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);121 115 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 122 116 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0); … … 251 245 RAD_TO_DEG(ecliptic->r),RAD_TO_DEG(ecliptic->d), 252 246 lambda[x], beta[x]); 253 //return 1;247 return 1; 254 248 } 255 249 if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE || … … 265 259 266 260 // apply/unapply Galactic 261 // if (x == 1){ 262 // psSphereRot *temp = psSphereRotICRSToGalactic(); 263 // *fromGalactic = *temp; 264 // fromGalactic->q3 *= -1.0; 265 // psFree(temp); 266 // } 267 267 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 268 268 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); … … 275 275 RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d), 276 276 l[x], b[x]); 277 // return 3; 277 printf("togal- %lf,%lf,%lf,%lf fromgal- %lf,%lf,%lf,%lf\n", 278 toGalactic->q0, toGalactic->q1, toGalactic->q2, toGalactic->q3, 279 fromGalactic->q0, fromGalactic->q1, fromGalactic->q2, fromGalactic->q3); 280 return 3; 278 281 } 279 282 if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE || … … 283 286 RAD_TO_DEG(icrsFromGalactic->r),RAD_TO_DEG(icrsFromGalactic->d), 284 287 alpha[x], delta[x]); 285 //return 4;288 return 4; 286 289 } 287 290 psFree(galactic); … … 316 319 psTime* fromTime = psTimeFromMJD(MJD_2100); 317 320 psTime* toTime = psTimeFromMJD(MJD_1900); 318 // psTime* fromTime = psTimeFromMJD(MJD_1900);319 // psTime* toTime = psTimeFromMJD(MJD_2100);320 321 321 322 // Set input coordinate … … 336 337 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 337 338 outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R); 338 //return 2;339 return 2; 339 340 } 340 341 if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) { 341 342 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 342 343 outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D); 343 //return 3;344 return 3; 344 345 } 345 346 psFree(outputCoord); … … 362 363 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 363 364 outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R); 364 //return 5;365 return 5; 365 366 } 366 367 if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) { 367 368 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 368 369 outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D); 369 //return 6;370 return 6; 370 371 } 371 372 psFree(outputCoord); … … 388 389 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 389 390 outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R); 390 //return 8;391 return 8; 391 392 } 392 393 if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) { … … 429 430 } 430 431 431 psS32 testSphereToFromCube(void) 432 { 432 psS32 testSphereOffset(void) 433 { 434 psSphere *origin = psSphereAlloc(); 435 psSphere *offset = psSphereAlloc(); 436 psSphere *dest = psSphereAlloc(); 437 psSphere *empty = NULL; 438 psSphere *output = NULL; 439 440 //Test Set for NULL position 441 output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE); 442 if (output != NULL) { 443 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 444 "psSphereSetOffset Failed to return NULL for NULL input.\n"); 445 return 1; 446 } 447 //Test Set for NULL offset 448 output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE); 449 if (output != NULL) { 450 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 451 "psSphereSetOffset Failed to return NULL for NULL input.\n"); 452 return 2; 453 } 454 //Test Get for NULL position1 455 output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN); 456 if (output != NULL) { 457 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 458 "psSphereGetOffset Failed to return NULL for NULL input.\n"); 459 return 3; 460 } 461 //Test Get for NULL position2 462 output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN); 463 if (output != NULL) { 464 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 465 "psSphereGetOffset Failed to return NULL for NULL input.\n"); 466 return 4; 467 } 468 469 //Test Set using Spherical mode, Degree units 470 origin->r = 0.0; 471 origin->d = 0.0; 472 offset->r = 45.0; 473 offset->d = 30.0; 474 output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE); 475 if ( fabs(output->r - M_PI/4.0) > 0.0001 || 476 fabs(output->d - M_PI/6.0) > 0.0001 ) { 477 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 478 "psSphereSetOffset failed to return correct spherical offset values.\n"); 479 return 5; 480 } 481 psFree(output); 482 483 //Test Set and Get using Linear mode, Radian units 484 origin->r = 0.0; 485 origin->d = 0.0; 486 offset->r = 1.0; 487 offset->d = 1.0; 488 output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN); 489 /* if ( fabs(output->r - 1.0) > 0.0001 || fabs(output->d - 1.0) > 0.0001 ) { 490 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 491 "psSphereSetOffset failed to return correct linear offset values.\n"); 492 printf("\n SphereSetOffset should be %lf, %lf and is %lf, %lf\n", offset->r, offset->d, 493 output->r, output->d); 494 return 6; 495 } 496 */ 497 output->r *= -1.0; 498 output->d *= -1.0; 499 empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN); 500 if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->r) > 0.0001 ) { 501 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 502 "psSphereGetOffset failed to return correct linear offset values.\n"); 503 return 7; 504 } 505 psFree(output); 506 psFree(empty); 507 508 //Test Set using Linear mode, Arcmin units 509 origin->r = 0.0; 510 origin->d = 0.0; 511 offset->r = RAD_TO_MIN(M_PI / 4.0); //45 deg 512 offset->d = RAD_TO_MIN(M_PI / 6.0); //30 deg 513 output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_ARCMIN); 514 //Test Get using Spherical mode, Arcsec units 515 empty = psSphereGetOffset(origin, output, PS_SPHERICAL, PS_ARCSEC); 516 empty->r = SEC_TO_RAD(empty->r); 517 empty->d = SEC_TO_RAD(empty->d); 518 if (fabs(empty->r - (M_PI / 4.0)) > 0.001 || fabs(empty->d - (M_PI / 6.0)) > 0.001) { 519 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 520 "psSphereGetOffset failed to return correct offset unit values.\n"); 521 printf("\n SphereGetOffset should be %lf, %lf and is %lf, %lf\n", output->r, output->d, 522 empty->r, empty->d); 523 return 8; 524 } 525 psFree(output); 526 527 psFree(origin); 528 psFree(dest); 529 psFree(offset); 530 psFree(empty); 531 433 532 return 0; 434 533 } 435 534 436 psS32 testSphereOffset(void)437 {438 return 0;439 }440
Note:
See TracChangeset
for help on using the changeset viewer.
