Changeset 6309 for trunk/psLib/test/astro/tst_psSphereOps.c
- Timestamp:
- Feb 2, 2006, 1:19:58 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/astro/tst_psSphereOps.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/tst_psSphereOps.c
r6226 r6309 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-0 1-27 20:08:58 $7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-02-02 23:19:58 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 64 64 double a2 = (ALPHA_P + PHI_P)/2.0; 65 65 double a3 = (ALPHA_P + PHI_P)/2.0; 66 66 //From Mathworld, this is another way to calculate the quaternions of a rotation 67 67 double q0 = sin(a0)*sin(DELTA_P/2); 68 68 double q1 = cos(a1)*sin(DELTA_P/2); 69 69 double q2 = sin(a2)*cos(DELTA_P/2); 70 70 double q3 = cos(a3)*cos(DELTA_P/2); 71 71 //Check that the quaternion components all match 72 72 if (DBL_EPSILON < fabs(q0 - myST->q0)) { 73 73 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0); … … 99 99 double a2 = (ALPHA_P + PHI_P)/2.0; 100 100 double a3 = (ALPHA_P + PHI_P)/2.0; 101 101 //From Mathworld, this is another way to calculate the quaternions of a rotation 102 102 double q0 = sin(a0)*sin(DELTA_P/2); 103 103 double q1 = cos(a1)*sin(DELTA_P/2); … … 111 111 return 1; 112 112 } 113 113 //Check that the quaternion components all match 114 114 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 115 115 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0); … … 135 135 } 136 136 137 138 137 // We do a simple identity transformation on a few RA, DEC pairs. 139 138 psS32 testSphereRotApply1( void ) 140 139 { 141 142 140 psSphere *in = psSphereAlloc(); 143 141 psSphere *out = psSphereAlloc(); … … 145 143 psSphere *rc = NULL; 146 144 psSphere *temp2 = psSphereAlloc(); 147 // psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0);148 145 psSphereRot *myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); 149 146 psSphereRot *yourST = psSphereRotInvert(ALPHA_P, DELTA_P, PHI_P); … … 155 152 in->rErr = 0.0; 156 153 in->dErr = 0.0; 157 154 //Here we apply the sphere rotation, then the inverse 158 155 temp2 = psSphereRotApply(temp2, myST, in); 159 156 out = psSphereRotApply(out, yourST, temp2); 160 157 //Check that out matches in 161 158 if (ERROR_TOL < fabs(out->r - in->r)) { 162 159 psError(PS_ERR_UNKNOWN,true,"out->r is %f, should be %f\n", out->r, in->r); … … 206 203 psS32 testSphereRotApplyCelestial( void) 207 204 { 205 //Test cases below were provided in ADD. 208 206 int numTestPoints = 3; 209 207 // ICRS coordinates … … 220 218 221 219 for (int x = 0; x < numTestPoints; x++) { 222 220 //Setup the appropriate rotations 223 221 psTime* time = psTimeFromMJD(t[x]); 224 222 psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time); … … 246 244 return 1; 247 245 } 246 //The second condition here (d - 90) is used b/c 90 is a pole. 248 247 if ( (fabs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE && 249 248 fabs(RAD_TO_DEG(icrsFromEcliptic->d) - 90.0) > TOLERANCE ) || … … 258 257 psFree(icrsFromEcliptic); 259 258 260 // apply/unapply Galactic 261 // if (x == 1){ 262 // psSphereRot *temp = psSphereRotICRSToGalactic(); 263 // *fromGalactic = *temp; 264 // fromGalactic->q3 *= -1.0; 265 // psFree(temp); 266 // } 259 //Setup galactic transformations 267 260 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 268 261 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); … … 277 270 return 3; 278 271 } 272 //The second condition here (d - 90) is used b/c 90 is a pole. 279 273 if ( (fabs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE && 280 274 fabs(RAD_TO_DEG(icrsFromGalactic->d) - 90.0) > TOLERANCE ) || … … 306 300 307 301 //Test Set for NULL position 302 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 308 303 output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE); 309 304 if (output != NULL) { … … 313 308 } 314 309 //Test Set for NULL offset 310 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 315 311 output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE); 316 312 if (output != NULL) { … … 320 316 } 321 317 //Test Get for NULL position1 318 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 322 319 output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN); 323 320 if (output != NULL) { … … 327 324 } 328 325 //Test Get for NULL position2 326 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 329 327 output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN); 330 328 if (output != NULL) { … … 354 352 offset->d = 1.0; 355 353 output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN); 356 /* if ( fabs(output->r - 1.0) > 0.0001 || fabs(output->d - 1.0) > 0.0001 ) { 357 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 358 "psSphereSetOffset failed to return correct linear offset values.\n"); 359 printf("\n SphereSetOffset should be %lf, %lf and is %lf, %lf\n", offset->r, offset->d, 360 output->r, output->d); 361 return 6; 362 } 363 */ 364 // output->r *= -1.0; 365 // output->d *= -1.0; 354 366 355 empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN); 367 356 if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->d) > 0.0001 ) {
Note:
See TracChangeset
for help on using the changeset viewer.
