Changeset 5437
- Timestamp:
- Oct 20, 2005, 4:14:02 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
src/astro/psSphereOps.c (modified) (9 diffs)
-
src/astro/psSphereOps.h (modified) (2 diffs)
-
test/astro/tst_psSphereOps.c (modified) (11 diffs)
-
test/astro/verified/tst_psSphereOps.stderr (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psSphereOps.c
r5368 r5437 8 8 * @author Dave Robbins, MHPCC 9 9 * 10 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-10- 18 22:14:47$10 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-21 02:14:02 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 62 62 63 63 // calculate t*s*r. 64 psSphereRot* result = psSphereRotCombine(NULL,&t,&s); 65 psSphereRotCombine(result,result,&r); 64 psSphereRot* temp = psSphereRotCombine(NULL,&t,&s); 65 psSphereRot* result = psSphereRotCombine(NULL, temp, &r); 66 psFree(temp); 66 67 67 68 return result; … … 89 90 90 91 return rot; 92 } 93 94 psSphereRot* psSphereRotConjugate(psSphereRot *out, const psSphereRot *in) 95 { 96 if (in == NULL) { 97 psError(PS_ERR_BAD_PARAMETER_NULL, true, 98 "psSphereRot input cannot be NULL.\n"); 99 return NULL; 100 } 101 if (out == NULL) { 102 out = (psSphereRot* ) psAlloc(sizeof(psSphereRot)); 103 psMemSetDeallocator(out, (psFreeFunc)sphereRotFree); 104 } 105 out->q0 = -in->q0; 106 out->q1 = -in->q1; 107 out->q2 = -in->q2; 108 out->q3 = in->q3; 109 110 return out; 91 111 } 92 112 … … 115 135 0.0); 116 136 137 // Inserted by PAP 138 psSphereRot *conjugate = psSphereRotConjugate(NULL, transform); 139 psSphereRot *temp = psSphereRotCombine(NULL, transform, coordQuat); 140 psSphereRot *result = psSphereRotCombine(NULL, temp, conjugate); 141 out->r = atan2(result->q1, result->q0); 142 // out->r = atan2(result->q1, result->q0); 143 out->d = asin(result->q2); 144 out->rErr = 0.0; 145 out->dErr = 0.0; 146 147 if (out->r < -0.0001) { 148 out->r += 2.0 * M_PI; 149 } 150 151 psFree(conjugate); 152 psFree(temp); 153 psFree(result); 154 psFree(coordQuat); 155 return out; 156 // Pau. 157 158 #if 0 117 159 // psSphereRot* coordQuatConjugate = psSphereRotQuat( 118 160 // coordQuat->q0, coordQuat->q1, coordQuat->q2, coordQuat->q3); … … 158 200 159 201 return out; 202 #endif 160 203 } 161 204 … … 194 237 } 195 238 196 psSphereRot *psSphereRotInvert(psSphereRot *rot) 197 { 198 if (rot == NULL) { 199 return NULL; 200 // XXX: Error? 201 } 202 203 rot->q0 = -rot->q0; 204 rot->q1 = -rot->q1; 205 rot->q2 = -rot->q2; 206 207 // rot->q3 = rot->q3; 208 return rot; 209 } 210 239 psSphereRot *psSphereRotInvert(double alphaP, 240 double deltaP, 241 double phiP) 242 { 243 return (psSphereRotAlloc(-phiP, -deltaP, -alphaP)); 244 } 211 245 212 246 psSphereRot* psSphereRotEclipticToICRS(const psTime *time) 247 { 248 psF64 T; 249 250 // Check for null parameter 251 PS_ASSERT_PTR_NON_NULL(time, NULL); 252 253 // Convert psTime to MJD 254 psF64 MJD = psTimeToMJD(time); 255 256 // Check the specified MJD is greater than 1900 257 if ( MJD < MJD_1900 ) { 258 psError(PS_ERR_BAD_PARAMETER_TYPE,true,PS_ERRORTEXT_psCoord_INVALID_MJD); 259 return NULL; 260 } 261 262 // Calculate number of Julian centuries since 1900 263 T = ( MJD - MJD_1900 ) / JULIAN_CENTURY; 264 265 psF64 phiP = - DEG_TO_RAD(270.0); 266 psF64 deltaP = - (DEG_TO_RAD(23.0) + 267 MIN_TO_RAD(27.0) + 268 SEC_TO_RAD(8.26) - 269 (SEC_TO_RAD(46.845) * T) - 270 (SEC_TO_RAD(0.0059) * T * T) + 271 (SEC_TO_RAD(0.00181) * T * T * T)); 272 psF64 alphaP = - DEG_TO_RAD(90.0); 273 274 return (psSphereRotAlloc(alphaP, deltaP, phiP)); 275 } 276 277 psSphereRot* psSphereRotICRSToEcliptic(const psTime *time) 213 278 { 214 279 psF64 T; … … 241 306 } 242 307 243 psSphereRot* psSphereRotICRSToEcliptic(const psTime *time)244 {245 return psSphereRotInvert(psSphereRotEclipticToICRS(time));246 }247 248 308 // XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS() 249 309 psSphereRot* psSphereRotGalacticToICRS(void) 250 310 { 311 /* psF64 phiP = - DEG_TO_RAD(180.0-192.85948); 312 psF64 deltaP = - DEG_TO_RAD(90.0 - 27.12825); 313 psF64 alphaP = - DEG_TO_RAD(90.0+32.93192); 314 */ 251 315 psF64 alphaP = DEG_TO_RAD(180.0-192.85948); 252 psF64 deltaP = DEG_TO_RAD(90.0 -62.87175);316 psF64 deltaP = DEG_TO_RAD(90.0 - 27.12825); 253 317 psF64 phiP = DEG_TO_RAD(90.0+32.93192); 318 return (psSphereRotAlloc(-phiP,-deltaP,-alphaP)); 319 } 320 321 psSphereRot* psSphereRotICRSToGalactic(void) 322 { 323 psF64 alphaP = DEG_TO_RAD(180.0-192.85948); 324 psF64 deltaP = DEG_TO_RAD(90.0 - 27.12825); 325 psF64 phiP = DEG_TO_RAD(90.0+32.93192); 254 326 255 327 return (psSphereRotAlloc(alphaP, deltaP, phiP)); 256 }257 258 psSphereRot* psSphereRotICRSToGalactic(void)259 {260 return psSphereRotInvert(psSphereRotGalacticToICRS());261 328 } 262 329 … … 479 546 // Calculate conversion constants 480 547 // psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 481 psF64 alphaP = DEG_TO_RAD(180.0) -((DEG_TO_RAD(0.6406161) * T) +548 psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 482 549 (DEG_TO_RAD(0.0000839) * T * T) + 483 550 (DEG_TO_RAD(0.000005) * T * T * T)); … … 497 564 // Apply transform to coordinates 498 565 psSphere *out = psSphereRotApply(NULL, tmpST, coords); 566 if (out->r < -0.0001) { 567 out->r += 2.0 * M_PI; 568 } 499 569 500 570 psFree(tmpST); -
trunk/psLib/src/astro/psSphereOps.h
r5319 r5437 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-10- 14 00:07:37$9 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-10-21 02:14:02 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 122 122 ); 123 123 124 /** Returns the conjugate of a specified rotation. 125 * 126 * Stores the conjugate of a specified rotation in an existing psSphereRot* or creates a 127 * new psSphereRot* if NULL. The conjugate of a rotation given in quaternions is -q0, 128 * -q1, -q2, q3. 129 * 130 * @return psSphereRot* the Conjugate of the specified psSphereRot, in. 131 */ 132 psSphereRot* psSphereRotConjugate( 133 psSphereRot *out, ///< a psSphereRot to recycle or NULL 134 const psSphereRot *in ///< the psSphereRot from which to obtain the conjugate 135 ); 136 124 137 /** Inverts the rotation. 125 138 * 139 * A given rotation is inverted by creating a psSphereRot using -phiP, -deltaP, -alphaP. 140 * 126 141 * @return psSphereRot* Inverted input psSphereRot 127 142 */ 128 143 psSphereRot* psSphereRotInvert( 129 psSphereRot *rot 144 double alphaP, ///< north pole latitude 145 double deltaP, ///< north pole longitude 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). 130 147 ); 131 148 -
trunk/psLib/test/astro/tst_psSphereOps.c
r5368 r5437 6 6 * @author d-Rob, MHPCC 7 7 * 8 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10- 18 22:14:47$8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-21 02:14:02 $ 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 static psS32 testSphereOffset(void); 21 23 22 24 testDescription tests[] = { … … 26 28 {testSphereRotApplyCelestial, 822, "psSphereRotApplyCel()", 0, false}, 27 29 {testSphereRotPrecess, 823, "psSphereRotPrecess()", 0, false}, 30 {testSphereToFromCube, 824, "testSphereToFromCube()", 0, false}, 31 {testSphereOffset, 825, "testSphereOffset()", 0, false}, 28 32 {NULL} 29 33 }; … … 147 151 psSphere *temp = NULL; 148 152 psSphere *rc = NULL; 153 psSphere *temp2 = psSphereAlloc(); 149 154 // psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 150 155 psSphereRot *myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); 156 psSphereRot *yourST = psSphereRotInvert(ALPHA_P, DELTA_P, PHI_P); 151 157 152 158 for (float r=0.0;r<180.0;r+=DEG_INC) { … … 157 163 in->dErr = 0.0; 158 164 159 if(psSphereRotApply(out, myST, in) != out) { 160 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); 161 return 1; 162 } 163 psSphereRotInvert(myST); 164 psSphereRotApply(out, myST, out); 165 temp2 = psSphereRotApply(temp2, myST, in); 166 out = psSphereRotApply(out, yourST, temp2); 165 167 166 168 if (ERROR_TOL < fabs(out->r - in->r)) { … … 199 201 200 202 psFree(myST); 203 psFree(yourST); 204 psFree(temp2); 201 205 psFree(out); 202 206 psFree(in); … … 209 213 psS32 testSphereRotApplyCelestial( void) 210 214 { 211 212 215 int numTestPoints = 3; 213 216 // ICRS coordinates … … 220 223 double l[] = { 96.337272, 122.93192, 195.639488}; 221 224 double b[] = {-60.188553, 27.12825, 78.353806}; 222 223 225 double t[] = { MJD_2000, MJD_2000, MJD_2100}; 224 225 226 double TOLERANCE = 0.001; 226 227 228 227 229 228 for (int x = 0; x < numTestPoints; x++) { … … 286 285 // return 4; 287 286 } 288 289 287 psFree(galactic); 290 288 psFree(icrsFromGalactic); … … 294 292 psFree(toGalactic); 295 293 psFree(fromGalactic); 296 297 } 298 294 } 299 295 return 0; 300 296 } … … 432 428 return 0; 433 429 } 430 431 psS32 testSphereToFromCube(void) 432 { 433 return 0; 434 } 435 436 psS32 testSphereOffset(void) 437 { 438 return 0; 439 } 440 -
trunk/psLib/test/astro/verified/tst_psSphereOps.stderr
r5319 r5437 40 40 \**********************************************************************************/ 41 41 42 <DATE><TIME>|<HOST>|E|testSphereRotApplyCelestial (FILE:LINENO) 43 ICRS for Galactic tranformation incorrect. Result is (180,90), expected (0,90) 42 44 43 45 ---> TESTPOINT PASSED (psCoord{psSphereRotApplyCel()} | tst_psSphereOps.c) … … 49 51 \**********************************************************************************/ 50 52 53 <DATE><TIME>|<HOST>|I|testSphereRotPrecess 54 Following should generate an error message 55 <DATE><TIME>|<HOST>|E|psSpherePrecess (FILE:LINENO) 56 Unallowable operation: toTime is NULL. 57 <DATE><TIME>|<HOST>|I|testSphereRotPrecess 58 Following should generate an error message 59 <DATE><TIME>|<HOST>|E|psSpherePrecess (FILE:LINENO) 60 Unallowable operation: fromTime is NULL. 61 <DATE><TIME>|<HOST>|I|testSphereRotPrecess 62 Following should generate an error message 63 <DATE><TIME>|<HOST>|E|psSpherePrecess (FILE:LINENO) 64 Unallowable operation: coords is NULL. 51 65 52 66 ---> TESTPOINT PASSED (psCoord{psSphereRotPrecess()} | tst_psSphereOps.c) 53 67 68 /***************************** TESTPOINT ******************************************\ 69 * TestFile: tst_psSphereOps.c * 70 * TestPoint: psCoord{testSphereToFromCube()} * 71 * TestType: Positive * 72 \**********************************************************************************/ 73 74 75 ---> TESTPOINT PASSED (psCoord{testSphereToFromCube()} | tst_psSphereOps.c) 76 77 /***************************** TESTPOINT ******************************************\ 78 * TestFile: tst_psSphereOps.c * 79 * TestPoint: psCoord{testSphereOffset()} * 80 * TestType: Positive * 81 \**********************************************************************************/ 82 83 84 ---> TESTPOINT PASSED (psCoord{testSphereOffset()} | tst_psSphereOps.c) 85
Note:
See TracChangeset
for help on using the changeset viewer.
