Changeset 5254 for trunk/psLib/test/astro/tst_psSphereOps.c
- Timestamp:
- Oct 7, 2005, 5:51:20 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/astro/tst_psSphereOps.c (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/tst_psSphereOps.c
r5235 r5254 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10-0 7 21:27:50 $8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-08 03:51:20 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 48 48 #define ERROR_TOL 0.0001 49 49 50 #define ALPHA_P 1.051 #define DELTA_P 2.052 #define PHI_P 3.050 #define ALPHA_P 0.5 * M_PI 51 #define DELTA_P 1.0 * M_PI 52 #define PHI_P 1.5 * M_PI 53 53 54 54 psS32 testSphereRotAlloc( void ) … … 63 63 } 64 64 // Verify sin member is updated 65 // double vx = cos(DELTA_P)*cos(ALPHA_P); 66 // double vy = cos(DELTA_P)*sin(ALPHA_P); 67 // double vz = sin(DELTA_P); 68 // double q0 = vx * sin(PHI_P/2.0); 69 // double q1 = vy * sin(PHI_P/2.0); 70 // double q2 = vz * sin(PHI_P/2.0); 71 // double q3 = cos(PHI_P/2.0); 72 /* 73 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 74 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0); 75 return 2; 76 } 77 if (FLT_EPSILON < fabs(q1 - myST->q1)) { 78 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1); 79 return 3; 80 } 81 if (FLT_EPSILON < fabs(q2 - myST->q2)) { 82 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2); 83 return 4; 84 } 85 if (FLT_EPSILON < fabs(q3 - myST->q3)) { 86 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3); 87 return 5; 88 } 89 */ 65 double vx = cos(DELTA_P)*cos(ALPHA_P); 66 double vy = cos(DELTA_P)*sin(ALPHA_P); 67 double vz = sin(DELTA_P); 68 double q0 = vx * sin(PHI_P/2.0); 69 double q1 = vy * sin(PHI_P/2.0); 70 double q2 = vz * sin(PHI_P/2.0); 71 double q3 = cos(PHI_P/2.0); 72 double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); 73 printf("\nvz = %lf\n", vz); 74 q0 = q0/len; 75 q1 = q1/len; 76 q2 = q2/len; 77 q3 = q3/len; 78 79 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 80 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0); 81 return 2; 82 } 83 if (FLT_EPSILON < fabs(q1 - myST->q1)) { 84 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1); 85 return 3; 86 } 87 if (FLT_EPSILON < fabs(q2 - myST->q2)) { 88 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2); 89 return 4; 90 } 91 if (FLT_EPSILON < fabs(q3 - myST->q3)) { 92 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3); 93 return 5; 94 } 95 90 96 // Free data structure 91 97 psFree(myST); … … 103 109 psSphere *rc = NULL; 104 110 psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 105 111 106 112 for (float r=0.0;r<180.0;r+=DEG_INC) { 107 113 for (float d=0.0;d<90.0;d+=DEG_INC) { … … 110 116 in->rErr = 0.0; 111 117 in->dErr = 0.0; 112 118 113 119 if(psSphereRotApply(out, myST, in) != out) { 114 120 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); … … 125 131 } 126 132 } 127 133 128 134 // Verify new sphere object is created if out parameter NULL 129 135 temp = psSphereRotApply(NULL, myST, in); … … 133 139 } 134 140 psFree(temp); 135 141 136 142 // Verify NULL returned if transform structure null 137 143 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); … … 141 147 return 5; 142 148 } 143 149 144 150 // Verify NULL returned when input sphere is NULL 145 151 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); … … 149 155 return 6; 150 156 } 151 157 152 158 psFree(myST); 153 159 psFree(out); … … 180 186 psSphereRot *mySphereRotForward = NULL; 181 187 psSphereRot *mySphereRotReverse = NULL; 182 183 188 189 184 190 mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0), 185 191 0.0, … … 188 194 0.0, 189 195 0.0); 190 196 191 197 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 192 198 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { … … 195 201 in.rErr = 0.0; 196 202 in.dErr = 0.0; 197 203 198 204 psSphereRotApply(&out, mySphereRotForward, &in); 199 205 psSphereRotApply(&out2, mySphereRotReverse, &out); 200 206 201 207 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 202 208 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { … … 210 216 psFree(mySphereRotForward); 211 217 psFree(mySphereRotReverse); 212 218 213 219 mySphereRotForward = psSphereRotAlloc(0.0, 214 220 DEG_TO_RAD(33.0), … … 223 229 in.rErr = 0.0; 224 230 in.dErr = 0.0; 225 231 226 232 psSphereRotApply(&out, mySphereRotForward, &in); 227 233 psSphereRotApply(&out2, mySphereRotReverse, &out); 228 234 229 235 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 230 236 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { … … 238 244 psFree(mySphereRotForward); 239 245 psFree(mySphereRotReverse); 240 246 241 247 return(testStatus); 242 248 */ … … 257 263 double l[] = { 96.337272, 122.93192, 195.639488}; 258 264 double b[] = {-60.188553, 27.12825, 78.353806}; 259 265 260 266 double t[] = { MJD_2000, MJD_2000, MJD_2100}; 261 267 262 268 double TOLERANCE = 0.001; 263 264 265 269 270 271 266 272 for (int x = 0; x < numTestPoints; x++) { 267 273 268 274 psTime* time = psTimeFromMJD(t[x]); 269 275 psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time); … … 272 278 psSphereRot* fromGalactic = psSphereRotGalacticToICRS(); 273 279 psFree(time); 274 280 275 281 // set the ICRS coordinate 276 282 psSphere* icrs = psSphereAlloc(); 277 283 icrs->r = DEG_TO_RAD(alpha[x]); 278 284 icrs->d = DEG_TO_RAD(delta[x]); 279 285 280 286 // apply/unapply Ecliptic 281 287 psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs); 282 288 psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic); 283 289 284 290 // check ecliptic transforms for correctness 285 291 if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE || … … 301 307 psFree(ecliptic); 302 308 psFree(icrsFromEcliptic); 303 309 304 310 // apply/unapply Galactic 305 311 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 306 312 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); 307 313 308 314 // check ecliptic transforms for correctness 309 315 if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE || … … 325 331 psFree(galactic); 326 332 psFree(icrsFromGalactic); 327 333 328 334 psFree(toEcliptic); 329 335 psFree(fromEcliptic); 330 336 psFree(toGalactic); 331 337 psFree(fromGalactic); 332 338 333 339 } 334 340 */ … … 356 362 psTime* fromTime = psTimeFromMJD(MJD_2100); 357 363 psTime* toTime = psTimeFromMJD(MJD_1900); 358 364 359 365 // Set input coordinate 360 366 inputCoord->r = SPHERE_PRECESS_TP1_R; … … 362 368 inputCoord->rErr = 0.0; 363 369 inputCoord->dErr = 0.0; 364 370 365 371 // Calculate precess 366 372 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 382 388 } 383 389 psFree(outputCoord); 384 390 385 391 // Set input coordinate 386 392 inputCoord->r = SPHERE_PRECESS_TP2_R; … … 388 394 inputCoord->rErr = 0.0; 389 395 inputCoord->dErr = 0.0; 390 396 391 397 // Calculate precess 392 398 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 408 414 } 409 415 psFree(outputCoord); 410 416 411 417 // Set input coordinate 412 418 inputCoord->r = SPHERE_PRECESS_TP3_R; … … 414 420 inputCoord->rErr = 0.0; 415 421 inputCoord->dErr = 0.0; 416 422 417 423 // Calculate precess 418 424 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 434 440 } 435 441 psFree(outputCoord); 436 442 437 443 // Invoke precess with invalid parameter 438 444 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 442 448 return 10; 443 449 } 444 450 445 451 // Invoke precess with invalid parameter 446 452 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 450 456 return 11; 451 457 } 452 458 453 459 // Invoke precess with invalid parameter 454 460 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 458 464 return 12; 459 465 } 460 466 461 467 // Free objects 462 468 psFree(fromTime);
Note:
See TracChangeset
for help on using the changeset viewer.
