Changeset 2930
- Timestamp:
- Jan 7, 2005, 1:52:00 PM (22 years ago)
- Location:
- trunk/psLib/test/astronomy
- Files:
-
- 2 edited
-
Makefile (modified) (2 diffs)
-
tst_psCoord.c (modified) (41 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astronomy/Makefile
r2681 r2930 3 3 ## Makefile: test/astronomy 4 4 ## 5 ## $Revision: 1.2 4$ $Name: not supported by cvs2svn $6 ## $Date: 200 4-12-10 02:50:15$5 ## $Revision: 1.25 $ $Name: not supported by cvs2svn $ 6 ## $Date: 2005-01-07 23:52:00 $ 7 7 ## 8 8 ## Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 tst_psMetadata_07 \ 33 33 tst_psAstrometry \ 34 tst_psCoord \ 34 35 tst_psAstrometry01 35 # tst_psCoord \36 36 37 37 OBJS = $(addprefix builddir/,$(addsuffix .o,$(TARGET))) -
trunk/psLib/test/astronomy/tst_psCoord.c
r2204 r2930 1 /** @file tst_ps ImageManip.c1 /** @file tst_psCoord.c 2 2 * 3 3 * @brief The code will ... … … 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 00:57:31 $ 8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-01-07 23:52:00 $ 10 * 11 * XXX: Must test psSpherePrecess. 12 * XXX: psSphereSetOffset(&position1, &offset, PS_LINEAR, 0) doesn't work? 10 13 * 11 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 17 #include "psTest.h" 15 18 #include "pslib.h" 16 17 19 static psS32 test1( void ); 18 20 static psS32 test1b( void ); … … 29 31 static psS32 test40( void ); 30 32 static psS32 test41( void ); 31 32 33 testDescription tests[] = { 33 34 {test1, 0000, "psSphereTransformAlloc()", 0, false}, … … 50 51 #define ARCSEC_TO_RAD (M_PI / (180.0 * 60.0 * 60.0)) 51 52 #define ARCMIN_TO_RAD (M_PI / (180.0 * 60.0)) 52 #define DEG_TO_RAD (M_PI / 180.0)53 #define RAD_TO_DEG (180.0 / M_PI)53 #define MY_DEG_TO_RAD (M_PI / 180.0) 54 #define MY_RAD_TO_DEG (180.0 / M_PI) 54 55 #define RAD_TO_ARCMIN ((180.0 * 60.0) / M_PI) 55 56 #define RAD_TO_ARCSEC ((180.0 * 60.0 * 60.0) / M_PI) … … 60 61 psLogSetLevel( PS_LOG_INFO ); 61 62 62 return ( ! runTestSuite( stderr, "ps Image", tests, argc, argv ) );63 return ( ! runTestSuite( stderr, "psCoord", tests, argc, argv ) ); 63 64 } 64 65 … … 66 67 #define PS_COMPARE_TINY_THEN_PRINT_ERROR(ACTUAL, EXPECT, TESTSTATUS) \ 67 68 if (MY_TINY < fabs(EXPECT - ACTUAL)) { \ 68 printf("ERROR: %s is %f, should be %f \n", #ACTUAL, ACTUAL, EXPECT); \69 printf("ERROR: %s is %f, should be %f (testStatus = %d)\n", #ACTUAL, ACTUAL, EXPECT, TESTSTATUS); \ 69 70 testStatus = TESTSTATUS; \ 70 71 } 71 72 #define MY_TINY 0.0001 72 73 #define PS_COMPARE_EPSILON_THEN_PRINT_ERROR(ACTUAL, EXPECT, TESTSTATUS) \ 73 if ( MY_TINY< fabs(EXPECT - ACTUAL)) { \74 printf("ERROR: %s is %f, should be %f \n", #ACTUAL, ACTUAL, EXPECT); \74 if (FLT_EPSILON < fabs(EXPECT - ACTUAL)) { \ 75 printf("ERROR: %s is %f, should be %f (testStatus = %d)\n", #ACTUAL, ACTUAL, EXPECT, TESTSTATUS); \ 75 76 testStatus = TESTSTATUS; \ 76 77 } … … 83 84 } 84 85 85 #define NPLAT 1.0 86 #define X0_BIG 2.0 87 #define X0_SMALL 2.0 88 86 #define ALPHA_P 1.0 87 #define DELTA_P 2.0 88 #define PHI_P 3.0 89 89 psS32 test1( void ) 90 90 { 91 float tmpF32; 92 psS32 testStatus = 0; 93 psSphereTransform *myST = psSphereTransformAlloc(NPLAT, X0_BIG, X0_SMALL); 94 95 tmpF32 = sin(NPLAT); 96 if (FLT_EPSILON < fabs(tmpF32 - myST->sinPhi)) { 97 printf("ERROR: myST->sinPhi is %f, should be %f\n", myST->sinPhi, tmpF32); 98 testStatus = 1; 99 } 100 tmpF32 = cos(NPLAT); 101 if (FLT_EPSILON < fabs(tmpF32 - myST->cosPhi)) { 102 printf("ERROR: myST->cosPhi is %f, should be %f\n", myST->cosPhi, tmpF32); 103 testStatus = 2; 104 } 105 106 if (FLT_EPSILON < fabs(X0_BIG - myST->Xo)) { 107 printf("ERROR: myST->Xo is %f, should be %f\n", myST->Xo, X0_BIG); 91 psS32 testStatus = 0; 92 psSphereTransform *myST = psSphereTransformAlloc(ALPHA_P, DELTA_P, PHI_P); 93 94 psF32 sinDeltaP = sin(DELTA_P); 95 if (FLT_EPSILON < fabs(sinDeltaP - myST->sinDeltaP)) { 96 printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sinDeltaP); 97 testStatus = 1; 98 } 99 psF32 cosDeltaP = cos(DELTA_P); 100 if (FLT_EPSILON < fabs(cosDeltaP - myST->cosDeltaP)) { 101 printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cosDeltaP); 102 testStatus = 1; 103 } 104 105 if (FLT_EPSILON < fabs(ALPHA_P - myST->alphaP)) { 106 printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, ALPHA_P); 108 107 testStatus = 3; 109 108 } 110 109 111 if (FLT_EPSILON < fabs( X0_SMALL - myST->xo)) {112 printf("ERROR: myST-> xo is %f, should be %f\n", myST->xo, X0_SMALL);110 if (FLT_EPSILON < fabs(PHI_P - myST->phiP)) { 111 printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, PHI_P); 113 112 testStatus = 4; 114 113 } … … 144 143 testStatus = 1; 145 144 } 145 psFree(myPT); 146 147 printf("-------------------------------------------------------------------\n"); 148 printf("Calling psPlaneTransformAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 149 myPT = psPlaneTransformAlloc(-1.0, 1.0); 150 if (myPT != NULL) { 151 printf("TEST ERROR: psPlaneTransformAlloc() did not return NULL.\n"); 152 testStatus = false; 153 myPT = NULL; 154 } 155 156 printf("-------------------------------------------------------------------\n"); 157 printf("Calling psPlaneTransformAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 158 myPT = psPlaneTransformAlloc(1.0, -1.0); 159 if (myPT != NULL) { 160 printf("TEST ERROR: psPlaneTransformAlloc() did not return NULL.\n"); 161 testStatus = false; 162 myPT = NULL; 163 } 164 printf("-------------------------------------------------------------------\n"); 165 146 166 147 167 psFree(myPT); … … 190 210 191 211 psFree(myPD); 212 213 printf("-------------------------------------------------------------------\n"); 214 printf("Calling psPlaneDistortAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 215 myPD = psPlaneDistortAlloc(-1.0, 1.0, 1.0, 1.0); 216 if (myPD != NULL) { 217 printf("TEST ERROR: psPlaneDistortAlloc() did not return NULL.\n"); 218 testStatus = false; 219 myPD = NULL; 220 } 221 222 printf("-------------------------------------------------------------------\n"); 223 printf("Calling psPlaneDistortAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 224 myPD = psPlaneDistortAlloc(1.0, -1.0, 1.0, 1.0); 225 if (myPD != NULL) { 226 printf("TEST ERROR: psPlaneDistortAlloc() did not return NULL.\n"); 227 testStatus = false; 228 myPD = NULL; 229 } 230 231 printf("-------------------------------------------------------------------\n"); 232 printf("Calling psPlaneDistortAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 233 myPD = psPlaneDistortAlloc(1.0, 1.0, -1.0, 1.0); 234 if (myPD != NULL) { 235 printf("TEST ERROR: psPlaneDistortAlloc() did not return NULL.\n"); 236 testStatus = false; 237 myPD = NULL; 238 } 239 240 printf("-------------------------------------------------------------------\n"); 241 printf("Calling psPlaneDistortAlloc() with negative-order polynomial request. Should generate error, return NULL.\n"); 242 myPD = psPlaneDistortAlloc(1.0, 1.0, 1.0, -1.0); 243 if (myPD != NULL) { 244 printf("TEST ERROR: psPlaneDistortAlloc() did not return NULL.\n"); 245 testStatus = false; 246 myPD = NULL; 247 } 248 printf("-------------------------------------------------------------------\n"); 249 192 250 return(testStatus); 193 251 } … … 201 259 psPlane in; 202 260 psPlane out; 261 psPlane *rc; 203 262 psPlaneTransform pt; 263 psDPolynomial2D *tmp2DPoly = NULL; 204 264 205 265 pt.x = psDPolynomial2DAlloc(2, 2, PS_POLYNOMIAL_ORD); … … 226 286 } 227 287 288 printf("-------------------------------------------------------------------\n"); 289 printf("Calling psPlaneTransformApply() with NULL psPlaneTransform. Should generate error, return NULL.\n"); 290 rc = psPlaneTransformApply(NULL, NULL, &in); 291 if (rc != NULL) { 292 printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n"); 293 testStatus = false; 294 rc = NULL; 295 } 296 297 printf("-------------------------------------------------------------------\n"); 298 printf("Calling psPlaneTransformApply() with NULL psPlaneTransform->x. Should generate error, return NULL.\n"); 299 tmp2DPoly = pt.x; 300 pt.x = NULL; 301 rc = psPlaneTransformApply(NULL, &pt, &in); 302 if (rc != NULL) { 303 printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n"); 304 testStatus = false; 305 rc = NULL; 306 } 307 pt.x = tmp2DPoly; 308 309 printf("-------------------------------------------------------------------\n"); 310 printf("Calling psPlaneTransformApply() with NULL psPlaneTransform->y. Should generate error, return NULL.\n"); 311 tmp2DPoly = pt.y; 312 pt.y = NULL; 313 rc = psPlaneTransformApply(NULL, &pt, &in); 314 if (rc != NULL) { 315 printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n"); 316 testStatus = false; 317 rc = NULL; 318 } 319 pt.y = tmp2DPoly; 320 321 printf("-------------------------------------------------------------------\n"); 322 printf("Calling psPlaneTransformApply() with NULL input coords. Should generate error, return NULL.\n"); 323 rc = psPlaneTransformApply(NULL, &pt, NULL); 324 if (rc != NULL) { 325 printf("TEST ERROR: psPlaneTransformApply() did not return NULL.\n"); 326 testStatus = false; 327 rc = NULL; 328 } 329 330 printf("-------------------------------------------------------------------\n"); 228 331 psFree(pt.x); 229 332 psFree(pt.y); … … 242 345 psPlane out; 243 346 psPlaneDistort pt; 347 psPlane *rc = NULL; 348 psDPolynomial4D *tmp4DPoly = NULL; 244 349 245 350 pt.x = psDPolynomial4DAlloc(2, 2, 2, 2, PS_POLYNOMIAL_ORD); … … 270 375 } 271 376 377 printf("-------------------------------------------------------------------\n"); 378 printf("Calling psPlaneDistortApply() with NULL psPlaneDistort. Should generate error, return NULL.\n"); 379 rc = psPlaneDistortApply(NULL, NULL, &in, COLOR, MAGNITUDE); 380 if (rc != NULL) { 381 printf("TEST ERROR: psPlaneDistortApply() did not return NULL.\n"); 382 testStatus = false; 383 rc = NULL; 384 } 385 386 printf("-------------------------------------------------------------------\n"); 387 printf("Calling psPlaneDistortApply() with NULL psPlaneDistort->x. Should generate error, return NULL.\n"); 388 tmp4DPoly = pt.x; 389 pt.x = NULL; 390 rc = psPlaneDistortApply(NULL, &pt, &in, COLOR, MAGNITUDE); 391 if (rc != NULL) { 392 printf("TEST ERROR: psPlaneDistortApply() did not return NULL.\n"); 393 testStatus = false; 394 rc = NULL; 395 } 396 pt.x = tmp4DPoly; 397 398 printf("-------------------------------------------------------------------\n"); 399 printf("Calling psPlaneDistortApply() with NULL psPlaneDistort->y. Should generate error, return NULL.\n"); 400 tmp4DPoly = pt.y; 401 pt.y = NULL; 402 rc = psPlaneDistortApply(NULL, &pt, &in, COLOR, MAGNITUDE); 403 if (rc != NULL) { 404 printf("TEST ERROR: psPlaneDistortApply() did not return NULL.\n"); 405 testStatus = false; 406 rc = NULL; 407 } 408 pt.y = tmp4DPoly; 409 410 printf("-------------------------------------------------------------------\n"); 411 printf("Calling psPlaneDistortApply() with NULL input coords. Should generate error, return NULL.\n"); 412 rc = psPlaneDistortApply(NULL, &pt, NULL, COLOR, MAGNITUDE); 413 if (rc != NULL) { 414 printf("TEST ERROR: psPlaneDistortApply() did not return NULL.\n"); 415 testStatus = false; 416 rc = NULL; 417 } 418 419 420 421 printf("-------------------------------------------------------------------\n"); 272 422 psFree(pt.x); 273 423 psFree(pt.y); … … 282 432 psSphere in; 283 433 psSphere out; 434 psSphere *rc = NULL; 284 435 psSphereTransform *myST = psSphereTransformAlloc(0.0, 0.0, 0.0); 285 436 286 in.r = 45.0 * DEG_TO_RAD;287 in.d = 30.0 * DEG_TO_RAD;437 in.r = 45.0 * MY_DEG_TO_RAD; 438 in.d = 30.0 * MY_DEG_TO_RAD; 288 439 in.rErr = 0.0; 289 440 in.dErr = 0.0; … … 291 442 for (float r=0.0;r<180.0;r+=DEG_INC) { 292 443 for (float d=0.0;d<90.0;d+=DEG_INC) { 293 in.r = r * DEG_TO_RAD;294 in.d = d * DEG_TO_RAD;444 in.r = r * MY_DEG_TO_RAD; 445 in.d = d * MY_DEG_TO_RAD; 295 446 in.rErr = 0.0; 296 447 in.dErr = 0.0; … … 311 462 } 312 463 464 printf("-------------------------------------------------------------------\n"); 465 printf("Calling psSphereTransformApply() with NULL psSphereTransform. Should generate error, return NULL.\n"); 466 rc = psSphereTransformApply(NULL, NULL, &in); 467 if (rc != NULL) { 468 printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n"); 469 testStatus = false; 470 rc = NULL; 471 } 472 473 printf("-------------------------------------------------------------------\n"); 474 printf("Calling psSphereTransformApply() with NULL input coords. Should generate error, return NULL.\n"); 475 rc = psSphereTransformApply(NULL, myST, NULL); 476 if (rc != NULL) { 477 printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n"); 478 testStatus = false; 479 rc = NULL; 480 } 481 482 printf("-------------------------------------------------------------------\n"); 313 483 psFree(myST); 314 484 return(testStatus); … … 318 488 { 319 489 psS32 testStatus = 0; 490 491 // XXX: This test code is simply a copy of the original source code. 320 492 psTime* now = psTimeGetTime(PS_TIME_UTC); 321 493 struct tm *tm_time = psTimeToTM(now); 322 323 // XXX: This test code is simply a copy of the original source code. 324 double year = (double)(1900 + tm_time->tm_year); 325 double T = year / 100.0; 326 double phi = -23.452294 + 0.013013 * T + 0.000001639 * T * T - 0.000000503 * T * T * T; 327 psSphereTransform *myST = psSphereTransformICRSToEcliptic(*now); 328 329 if (FLT_EPSILON < fabs(sin(phi) - myST->sinPhi)) { 330 printf("ERROR: myST->sinPhi is %f, should be %f\n", myST->sinPhi, sin(phi)); 331 testStatus = 1; 332 } 333 334 if (FLT_EPSILON < fabs(cos(phi) - myST->cosPhi)) { 335 printf("ERROR: myST->cosPhi is %f, should be %f\n", myST->cosPhi, cos(phi)); 336 testStatus = 2; 337 } 338 339 if (FLT_EPSILON < fabs(0.0 - myST->Xo)) { 340 printf("ERROR: myST->Xo is %f, should be %f\n", myST->Xo, X0_BIG); 494 psF64 MJD = psTimeToMJD(now); 495 struct tm *tmTime = psTimeToTM(now); 496 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 497 psF64 T = year / 100.0; 498 psF64 expectedAlphaP = 0.0; 499 psF64 expectedDeltaP = DEG_TO_RAD(23.0) + 500 SEC_TO_RAD(27.0) + 501 MIN_TO_RAD(8.0) - 502 (SEC_TO_RAD(46.845) * T) - 503 (SEC_TO_RAD(0.0059) * T * T) + 504 (SEC_TO_RAD(0.00181) * T * T * T); 505 expectedDeltaP*= -1.0; 506 psF64 expectedPhiP = 0.0; 507 psFree(tmTime); 508 509 psSphereTransform *myST = psSphereTransformICRSToEcliptic(now); 510 511 if (FLT_EPSILON < fabs(sin(expectedDeltaP) - myST->sinDeltaP)) { 512 printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sin(expectedDeltaP)); 513 testStatus = 1; 514 } 515 516 if (FLT_EPSILON < fabs(cos(expectedDeltaP) - myST->cosDeltaP)) { 517 printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cos(expectedDeltaP)); 518 testStatus = 1; 519 } 520 521 if (FLT_EPSILON < fabs(expectedAlphaP - myST->alphaP)) { 522 printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, expectedAlphaP); 341 523 testStatus = 3; 342 524 } 343 525 344 if (FLT_EPSILON < fabs( 0.0 - myST->xo)) {345 printf("ERROR: myST-> xo is %f, should be %f\n", myST->xo, X0_SMALL);526 if (FLT_EPSILON < fabs(expectedPhiP - myST->phiP)) { 527 printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, expectedPhiP); 346 528 testStatus = 4; 347 529 } … … 350 532 psFree(tm_time); 351 533 psFree(now); 534 535 printf("-------------------------------------------------------------------\n"); 536 printf("Calling psSphereTransformICRSToEcliptic() with NULL input. Should generate error, return NULL.\n"); 537 myST = psSphereTransformICRSToEcliptic(NULL); 538 if (myST != NULL) { 539 printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n"); 540 testStatus = false; 541 myST = NULL; 542 } 543 352 544 return(testStatus); 353 545 } … … 359 551 psTime* now = psTimeGetTime(PS_TIME_UTC); 360 552 struct tm *tm_time = psTimeToTM(now); 361 362 // XXX: This test code is simply a copy of the original source code. 363 double year = (double)(1900 + tm_time->tm_year); 364 double T = year / 100.0; 365 double phi = +23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T; 366 psSphereTransform *myST = psSphereTransformEclipticToICRS(*now); 367 368 if (FLT_EPSILON < fabs(sin(phi) - myST->sinPhi)) { 369 printf("ERROR: myST->sinPhi is %f, should be %f\n", myST->sinPhi, sin(phi)); 370 testStatus = 1; 371 } 372 373 if (FLT_EPSILON < fabs(cos(phi) - myST->cosPhi)) { 374 printf("ERROR: myST->cosPhi is %f, should be %f\n", myST->cosPhi, cos(phi)); 375 testStatus = 2; 376 } 377 378 if (FLT_EPSILON < fabs(0.0 - myST->Xo)) { 379 printf("ERROR: myST->Xo is %f, should be %f\n", myST->Xo, X0_BIG); 553 psF64 MJD = psTimeToMJD(now); 554 struct tm *tmTime = psTimeToTM(now); 555 psF64 year = (psF64)(1900 - MJD + tmTime->tm_year); 556 psF64 T = year / 100.0; 557 psF64 expectedAlphaP = 0.0; 558 psF64 expectedDeltaP = DEG_TO_RAD(23.0) + 559 SEC_TO_RAD(27.0) + 560 MIN_TO_RAD(8.0) - 561 (SEC_TO_RAD(46.845) * T) - 562 (SEC_TO_RAD(0.0059) * T * T) + 563 (SEC_TO_RAD(0.00181) * T * T * T); 564 psF64 expectedPhiP = 0.0; 565 psSphereTransform *myST = psSphereTransformEclipticToICRS(now); 566 567 if (FLT_EPSILON < fabs(sin(expectedDeltaP) - myST->sinDeltaP)) { 568 printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sin(expectedDeltaP)); 569 testStatus = 1; 570 } 571 572 if (FLT_EPSILON < fabs(cos(expectedDeltaP) - myST->cosDeltaP)) { 573 printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cos(expectedDeltaP)); 574 testStatus = 1; 575 } 576 577 if (FLT_EPSILON < fabs(expectedAlphaP - myST->alphaP)) { 578 printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, expectedAlphaP); 380 579 testStatus = 3; 381 580 } 382 581 383 if (FLT_EPSILON < fabs( 0.0 - myST->xo)) {384 printf("ERROR: myST-> xo is %f, should be %f\n", myST->xo, X0_SMALL);582 if (FLT_EPSILON < fabs(expectedPhiP - myST->phiP)) { 583 printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, expectedPhiP); 385 584 testStatus = 4; 386 585 } … … 388 587 psFree(myST); 389 588 psFree(tm_time); 589 psFree(tmTime); 390 590 psFree(now); 391 return(testStatus); 392 } 393 591 592 printf("-------------------------------------------------------------------\n"); 593 printf("Calling psSphereTransformEclipticToICRS() with NULL input. Should generate error, return NULL.\n"); 594 myST = psSphereTransformEclipticToICRS(NULL); 595 if (myST != NULL) { 596 printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n"); 597 testStatus = false; 598 myST = NULL; 599 } 600 601 return(testStatus); 602 } 394 603 395 604 psS32 test7( void ) … … 397 606 psS32 testStatus = 0; 398 607 // XXX: This test code is simply a copy of the original source code. 399 double phi = 62.6;400 double Xo = 282.25;401 double xo = 33.0;608 psF64 expectedAlphaP = DEG_TO_RAD(32.93192); 609 psF64 expectedDeltaP = DEG_TO_RAD(-62.87175); 610 psF64 expectedPhiP = DEG_TO_RAD(282.85948); 402 611 psSphereTransform *myST = psSphereTransformICRSToGalatic(); 403 612 404 if (FLT_EPSILON < fabs(sin( phi) - myST->sinPhi)) {405 printf("ERROR: myST->sin Phi is %f, should be %f\n", myST->sinPhi, sin(phi));406 testStatus = 1; 407 } 408 409 if (FLT_EPSILON < fabs(cos( phi) - myST->cosPhi)) {410 printf("ERROR: myST->cos Phi is %f, should be %f\n", myST->cosPhi, cos(phi));411 testStatus = 2;412 } 413 414 if (FLT_EPSILON < fabs( Xo - myST->Xo)) {415 printf("ERROR: myST-> Xo is %f, should be %f\n", myST->Xo, Xo);613 if (FLT_EPSILON < fabs(sin(expectedDeltaP) - myST->sinDeltaP)) { 614 printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sin(expectedDeltaP)); 615 testStatus = 1; 616 } 617 618 if (FLT_EPSILON < fabs(cos(expectedDeltaP) - myST->cosDeltaP)) { 619 printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cos(expectedDeltaP)); 620 testStatus = 1; 621 } 622 623 if (FLT_EPSILON < fabs(expectedAlphaP - myST->alphaP)) { 624 printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, expectedAlphaP); 416 625 testStatus = 3; 417 626 } 418 627 419 if (FLT_EPSILON < fabs( xo - myST->xo)) {420 printf("ERROR: myST-> xo is %f, should be %f\n", myST->xo, xo);628 if (FLT_EPSILON < fabs(expectedPhiP - myST->phiP)) { 629 printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, expectedPhiP); 421 630 testStatus = 4; 422 631 } … … 430 639 psS32 testStatus = 0; 431 640 // XXX: This test code is simply a copy of the original source code. 432 double phi = -62.6;433 double Xo = 33.0;434 double xo = 282.25;641 psF64 expectedAlphaP = DEG_TO_RAD(282.85948); 642 psF64 expectedDeltaP = DEG_TO_RAD(62.87175); 643 psF64 expectedPhiP = DEG_TO_RAD(32.93192); 435 644 psSphereTransform *myST = psSphereTransformGalaticToICRS(); 436 645 437 if (FLT_EPSILON < fabs(sin( phi) - myST->sinPhi)) {438 printf("ERROR: myST->sin Phi is %f, should be %f\n", myST->sinPhi, sin(phi));439 testStatus = 1; 440 } 441 442 if (FLT_EPSILON < fabs(cos( phi) - myST->cosPhi)) {443 printf("ERROR: myST->cos Phi is %f, should be %f\n", myST->cosPhi, cos(phi));444 testStatus = 2;445 } 446 447 if (FLT_EPSILON < fabs( Xo - myST->Xo)) {448 printf("ERROR: myST-> Xo is %f, should be %f\n", myST->Xo, Xo);646 if (FLT_EPSILON < fabs(sin(expectedDeltaP) - myST->sinDeltaP)) { 647 printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sin(expectedDeltaP)); 648 testStatus = 1; 649 } 650 651 if (FLT_EPSILON < fabs(cos(expectedDeltaP) - myST->cosDeltaP)) { 652 printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cos(expectedDeltaP)); 653 testStatus = 1; 654 } 655 656 if (FLT_EPSILON < fabs(expectedAlphaP - myST->alphaP)) { 657 printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, expectedAlphaP); 449 658 testStatus = 3; 450 659 } 451 660 452 if (FLT_EPSILON < fabs( xo - myST->xo)) {453 printf("ERROR: myST-> xo is %f, should be %f\n", myST->xo, xo);661 if (FLT_EPSILON < fabs(expectedPhiP - myST->phiP)) { 662 printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, expectedPhiP); 454 663 testStatus = 4; 455 664 } … … 463 672 psS32 testStatus = 0; 464 673 psSphere in; 465 double R;466 674 double expectX; 467 675 double expectY; 468 676 psPlane *out; 469 677 psProjection myProjection; 470 myProjection.R = 20.0 * DEG_TO_RAD;471 myProjection.D = 10.0 * DEG_TO_RAD;678 myProjection.R = 20.0 * MY_DEG_TO_RAD; 679 myProjection.D = 10.0 * MY_DEG_TO_RAD; 472 680 myProjection.Xs = 1.0; 473 681 myProjection.Ys = 1.0; … … 475 683 for (float r=0.0;r<180.0;r+=DEG_INC) { 476 684 for (float d=0.0;d<90.0;d+=DEG_INC) { 477 in.r = r * DEG_TO_RAD;478 in.d = d * DEG_TO_RAD;685 in.r = r * MY_DEG_TO_RAD; 686 in.d = d * MY_DEG_TO_RAD; 479 687 in.rErr = 0.0; 480 688 in.dErr = 0.0; … … 485 693 myProjection.type = PS_PROJ_TAN; 486 694 out = psProject(&in, &myProjection); 487 488 R = PS_COT(in.r) * (180.0 / M_PI); 489 expectX = R * sin(in.d); 490 expectY = R * cos(in.d); 695 expectX = cos(in.r) * sin(in.d) / sin(in.r); 696 expectY = -cos(in.r) * cos(in.d) / sin(in.r); 491 697 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 1); 492 698 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 2); … … 498 704 myProjection.type = PS_PROJ_SIN; 499 705 out = psProject(&in, &myProjection); 500 501 R = cos(in.r) * (180.0 / M_PI); 502 expectX = R * sin(in.d); 503 expectY = R * cos(in.d); 706 expectX = cos(in.d) * sin(in.d); 707 expectY = -cos(in.d) * cos(in.d); 504 708 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 3); 505 709 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 4); … … 525 729 526 730 expectX = in.d; 527 expectY = log(tan( 45.0 + (0.5 * in.r))) * 180.0 / M_PI;731 expectY = log(tan(DEG_TO_RAD(45.0) + (0.5 * in.r))); 528 732 529 733 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 7); … … 537 741 out = psProject(&in, &myProjection); 538 742 539 double alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(in.r) * 540 cos(0.5 * in.d) * 0.5))); 541 expectX = 2.0 * alpha * cos(in.r) * sin(0.5 * in.d); 542 expectY = alpha * sin(in.d); 543 544 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 7); 545 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 8); 743 744 psF64 tmpF64 = PS_SQRT_F32(0.5 * (1.0 + (cos(in.r) * cos(0.5 * in.d)))); 745 tmpF64 = 1.0 / tmpF64; 746 expectX = 2.0 * tmpF64 * cos(in.r) * sin(0.5 * in.d); 747 expectY = sin(in.r) * tmpF64; 748 749 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 20); 750 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 21); 546 751 psFree(out); 547 752 … … 549 754 } 550 755 } 756 757 printf("-------------------------------------------------------------------\n"); 758 printf("Calling psProject() with NULL input coords. Should generate error, return NULL.\n"); 759 out = psProject(NULL, &myProjection); 760 if (out != NULL) { 761 printf("TEST ERROR: psSphereTransformEclipticToICRS() did not return NULL.\n"); 762 testStatus = false; 763 out = NULL; 764 } 765 766 printf("-------------------------------------------------------------------\n"); 767 printf("Calling psProject() with NULL psProjection. Should generate error, return NULL.\n"); 768 out = psProject(&in, NULL); 769 if (out != NULL) { 770 printf("TEST ERROR: psProject() did not return NULL.\n"); 771 testStatus = false; 772 out = NULL; 773 } 774 775 printf("-------------------------------------------------------------------\n"); 776 551 777 return(testStatus); 552 778 } … … 562 788 psSphere *out; 563 789 psProjection myProjection; 564 myProjection.R = 20.0 * DEG_TO_RAD;565 myProjection.D = 10.0 * DEG_TO_RAD;790 myProjection.R = 20.0 * MY_DEG_TO_RAD; 791 myProjection.D = 10.0 * MY_DEG_TO_RAD; 566 792 myProjection.Xs = 1.0; 567 793 myProjection.Ys = 1.0; … … 578 804 out = psDeproject(&in, &myProjection); 579 805 580 R = sqrt((in.x * in.x) + (in.y * in.y));581 expectD = p_psArg(-in.y, in.x);582 expectR = atan (180.0 / (R * M_PI));806 R = PS_SQRT_F32((in.x * in.x) + (in.y * in.y)); 807 expectD = atan(1.0 / R); 808 expectR = atan2(-in.y, in.x); 583 809 584 810 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 1); … … 646 872 } 647 873 } 874 875 printf("-------------------------------------------------------------------\n"); 876 printf("Calling psDeproject() with NULL input coords. Should generate error, return NULL.\n"); 877 out = psDeproject(NULL, &myProjection); 878 if (out != NULL) { 879 printf("TEST ERROR: psDeproject() did not return NULL.\n"); 880 testStatus = false; 881 out = NULL; 882 } 883 884 printf("-------------------------------------------------------------------\n"); 885 printf("Calling psDeproject() with NULL psProjection. Should generate error, return NULL.\n"); 886 out = psDeproject(&in, NULL); 887 if (out != NULL) { 888 printf("TEST ERROR: psDeproject() did not return NULL.\n"); 889 testStatus = false; 890 out = NULL; 891 } 892 893 printf("-------------------------------------------------------------------\n"); 894 648 895 return(testStatus); 649 896 } … … 656 903 psSphere *offset = NULL; 657 904 658 position1.r = 90.0 * DEG_TO_RAD;659 position1.d = 45.0 * DEG_TO_RAD;905 position1.r = 90.0 * MY_DEG_TO_RAD; 906 position1.d = 45.0 * MY_DEG_TO_RAD; 660 907 position1.rErr = 0.0; 661 908 position1.dErr = 0.0; … … 663 910 for (float r=0.0;r<180.0;r+=DEG_INC) { 664 911 for (float d=0.0;d<90.0;d+=DEG_INC) { 665 position2.r = r * DEG_TO_RAD;666 position2.d = d * DEG_TO_RAD;912 position2.r = r * MY_DEG_TO_RAD; 913 position2.d = d * MY_DEG_TO_RAD; 667 914 position2.rErr = 0.0; 668 915 position2.dErr = 0.0; … … 676 923 offset = psSphereGetOffset(&position1, &position2, 677 924 PS_SPHERICAL, PS_DEGREE); 678 offset->r = offset->r * DEG_TO_RAD;679 offset->d = offset->d * DEG_TO_RAD;925 offset->r = offset->r * MY_DEG_TO_RAD; 926 offset->d = offset->d * MY_DEG_TO_RAD; 680 927 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2); 681 928 PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3); … … 711 958 } 712 959 960 printf("-------------------------------------------------------------------\n"); 961 printf("Calling psSphereGetOffset() with NULL position1. Should generate error, return NULL.\n"); 962 offset = psSphereGetOffset(NULL, &position2, PS_LINEAR, 0); 963 if (offset != NULL) { 964 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n"); 965 testStatus = false; 966 offset = NULL; 967 } 968 969 printf("-------------------------------------------------------------------\n"); 970 printf("Calling psSphereGetOffset() with NULL position2. Should generate error, return NULL.\n"); 971 offset = psSphereGetOffset(&position1, NULL, PS_LINEAR, 0); 972 if (offset != NULL) { 973 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n"); 974 testStatus = false; 975 offset = NULL; 976 } 977 978 printf("-------------------------------------------------------------------\n"); 979 printf("Calling psSphereGetOffset() with bogus offset mode. Should generate error, return NULL.\n"); 980 offset = psSphereGetOffset(&position1, &position2, 0x54321, 0); 981 if (offset != NULL) { 982 printf("TEST ERROR: psSphereGetOffset() did not return NULL.\n"); 983 testStatus = false; 984 offset = NULL; 985 } 986 987 printf("-------------------------------------------------------------------\n"); 713 988 return(testStatus); 714 989 } … … 722 997 psSphere tmpOffset; 723 998 724 position1.r = 90.0 * DEG_TO_RAD;725 position1.d = 45.0 * DEG_TO_RAD;999 position1.r = 90.0 * MY_DEG_TO_RAD; 1000 position1.d = 45.0 * MY_DEG_TO_RAD; 726 1001 position1.rErr = 0.0; 727 1002 position1.dErr = 0.0; … … 729 1004 for (float r=0.0;r<180.0;r+=DEG_INC) { 730 1005 for (float d=0.0;d<90.0;d+=DEG_INC) { 731 offset.r = r * DEG_TO_RAD;732 offset.d = d * DEG_TO_RAD;1006 offset.r = r * MY_DEG_TO_RAD; 1007 offset.d = d * MY_DEG_TO_RAD; 733 1008 offset.rErr = 0.0; 734 1009 offset.dErr = 0.0; … … 740 1015 psFree(position2); 741 1016 742 tmpOffset.r = offset.r * RAD_TO_DEG;743 tmpOffset.d = offset.d * RAD_TO_DEG;1017 tmpOffset.r = offset.r * MY_RAD_TO_DEG; 1018 tmpOffset.d = offset.d * MY_RAD_TO_DEG; 744 1019 tmpOffset.rErr = 0.0; 745 1020 tmpOffset.dErr = 0.0; … … 783 1058 } 784 1059 785 return(testStatus); 786 } 1060 printf("-------------------------------------------------------------------\n"); 1061 printf("Calling psSphereSetOffset() with NULL position1. Should generate error, return NULL.\n"); 1062 position2 = psSphereSetOffset(NULL, &offset, PS_LINEAR, 0); 1063 if (position2 != NULL) { 1064 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n"); 1065 testStatus = false; 1066 position2 = NULL; 1067 } 1068 1069 printf("-------------------------------------------------------------------\n"); 1070 printf("Calling psSphereSetOffset() with NULL offset. Should generate error, return NULL.\n"); 1071 position2 = psSphereSetOffset(&position1, NULL, PS_LINEAR, 0); 1072 if (position2 != NULL) { 1073 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n"); 1074 testStatus = false; 1075 position2 = NULL; 1076 } 1077 1078 printf("-------------------------------------------------------------------\n"); 1079 printf("Calling psSphereSetOffset() with bogus offset mode. Should generate error, return NULL.\n"); 1080 position2 = psSphereSetOffset(&position1, &offset, 0x54321, 0); 1081 if (position2 != NULL) { 1082 printf("TEST ERROR: psSphereSetOffset() did not return NULL.\n"); 1083 testStatus = false; 1084 position2 = NULL; 1085 } 1086 1087 printf("-------------------------------------------------------------------\n"); 1088 return(testStatus); 1089 } 1090 1091 // This code will ...
Note:
See TracChangeset
for help on using the changeset viewer.
