Changeset 5437 for trunk/psLib/src/astro/psSphereOps.c
- Timestamp:
- Oct 20, 2005, 4:14:02 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psSphereOps.c (modified) (9 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);
Note:
See TracChangeset
for help on using the changeset viewer.
