Changeset 2635
- Timestamp:
- Dec 6, 2004, 9:49:36 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 6 edited
-
astro/psCoord.c (modified) (16 diffs)
-
astro/psCoord.h (modified) (2 diffs)
-
astronomy/psCoord.c (modified) (16 diffs)
-
astronomy/psCoord.h (modified) (2 diffs)
-
dataManip/psConstants.h (modified) (2 diffs)
-
math/psConstants.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r2602 r2635 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 3 19:43:43$12 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-06 19:49:36 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 /******************************************************************************/ 20 20 #include "psType.h" 21 #include "psImage.h"22 #include "psArray.h"23 #include "psList.h"24 21 #include "psCoord.h" 25 22 #include "psMemory.h" … … 35 32 36 33 #define PS_COT(X) (1.0 / atan(X)) 34 #define DEG_TO_RAD(DEGREES) ((DEGREES) * M_PI / 180.0) 35 #define MIN_TO_RAD(MINUTES) ((MINUTES) * M_PI / (180.0 * 60.0)) 36 #define SEC_TO_RAD(SECONDS) ((SECONDS) * M_PI / (180.0 * 60.0 * 60.0)) 37 #define RAD_TO_DEG(RADIANS) ((RADIANS) * 180 / M_PI) 38 #define RAD_TO_MIN(RADIANS) ((RADIANS) * 180 * 60.0 / M_PI) 39 #define RAD_TO_SEC(RADIANS) ((RADIANS) * 180 * 60.0 * 60.0 / M_PI) 37 40 38 41 /******************************************************************************/ … … 162 165 163 166 /****************************************************************************** 164 This function prototype has been modified since the SDRS. 165 *****************************************************************************/ 166 psSphereTransform* psSphereTransformAlloc(double alphaP, 167 double deltaP, 168 double phiP) 167 alpha is LONGITUDE 168 delta is LATITUDE 169 170 alphaP: Take the target pole in the source system; calculate its LONGITUDE 171 in the target system. That longitude is alphaP. 172 DeltaP: Take the target pole in the source system; calculate its LATITUDE 173 in the target system. That longitude is deltaP. 174 phiP: This is the LONGITUDE of the ascending node in the target system. 175 *****************************************************************************/ 176 psSphereTransform* psSphereTransformAlloc(psF64 alphaP, 177 psF64 deltaP, 178 psF64 phiP) 169 179 { 170 180 psSphereTransform* tmp = (psSphereTransform* ) psAlloc(sizeof(psSphereTransform)); … … 179 189 180 190 /****************************************************************************** 181 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 182 (r,d) in the sphere coordinates. 183 184 XXX: In Gene's email, there are different variables with similar names (y 185 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 186 are no typo's. 191 XXX: It's not clear if this code correctly implements what the equations in 192 the ADD imply. Bug 243 will, hopefully, decide that. 193 194 XXX: Once this code is verified, delete Gene's code. 187 195 *****************************************************************************/ 188 196 psSphere* psSphereTransformApply(psSphere* out, … … 193 201 PS_PTR_CHECK_NULL(coord, NULL); 194 202 195 double sinY = 0.0;196 double cosY = 0.0;197 double sinX = 0.0;198 double cosX = 0.0;199 double x = 0.0;200 double y = 0.0;201 double dx = 0.0;202 203 203 if (out == NULL) { 204 204 out = (psSphere* ) psAlloc(sizeof(psSphere)); 205 205 } 206 206 207 x = coord->r; 208 y = coord->d; 209 dx = x - transform->phiP; 210 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 211 sin(y) * transform->cosDeltaP; 212 cosY = sqrt(1.0 - sinY * sinY); 213 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 214 sin(y) * transform->sinDeltaP) / cos(y); 215 cosX = cos(y) * cos(dx) / cos(y); 216 217 out->r = atan2(sinX, cosX) + transform->alphaP; 218 out->d = atan2(sinY, cosY); 219 220 return (out); 221 } 222 207 psF64 alpha = coord->r; 208 psF64 delta = coord->d; 209 psF64 alphaMinusAlphaP = alpha - transform->alphaP; 210 211 psF64 eq55 = (sin(delta) * transform->cosDeltaP) - 212 (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP)); 213 214 psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) + 215 (sin(delta) * transform->sinDeltaP); 216 217 psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP); 218 219 psF64 theta = asin(eq55); 220 psF64 phi = atan2(eq56, eq57) + transform->alphaP; 221 222 out->r = phi; 223 out->d = theta; 224 225 return(out); 226 227 /* 228 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 229 (r,d) in the sphere coordinates. 230 231 XXX: In Gene's email, there are different variables with similar names (y 232 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 233 are no typo's. 234 235 psF64 sinY = 0.0; 236 psF64 cosY = 0.0; 237 psF64 sinX = 0.0; 238 psF64 cosX = 0.0; 239 psF64 x = 0.0; 240 psF64 y = 0.0; 241 psF64 dx = 0.0; 242 243 x = coord->r; 244 y = coord->d; 245 dx = x - transform->phiP; 246 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 247 sin(y) * transform->cosDeltaP; 248 cosY = sqrt(1.0 - sinY * sinY); 249 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 250 sin(y) * transform->sinDeltaP) / cos(y); 251 cosX = cos(y) * cos(dx) / cos(y); 252 253 out->r = atan2(sinX, cosX) + transform->alphaP; 254 out->d = atan2(sinY, cosY); 255 */ 256 } 257 258 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 259 // there is no algorithm for this in the ADD. 260 // XXX: This is bug 244 223 261 psSphereTransform* psSphereTransformICRSToEcliptic(psTime time) 224 262 { … … 226 264 227 265 struct tm *tmTime = psTimeToTM(&time); 228 double year = (double)(1900 + tmTime->tm_year); 229 double T = year / 100.0; 230 double phi = -23.452294 + 0.013013 * T + 0.000001639 * T * T - 0.000000503 * T * T * T; 231 double alphaP = 0.0; 232 double phiP = 0.0; 266 psF64 year = (psF64)(1900 + tmTime->tm_year); 267 psF64 T = year / 100.0; 268 psF64 phi = DEG_TO_RAD(-23.452294) + 269 (DEG_TO_RAD(0.013013) * T) + 270 (DEG_TO_RAD(0.000001639) * T * T) - 271 (DEG_TO_RAD(0.000000503) * T * T * T); 272 psF64 alphaP = 0.0; 273 psF64 phiP = 0.0; 233 274 234 275 psFree(tmTime); … … 236 277 } 237 278 279 // XXX: the ADD changed. This code no longer conforms to the old ADD. 280 // XXX: Waiting for IfA to sepcify if T should include days/months/etc. 238 281 psSphereTransform* psSphereTransformEclipticToICRS(psTime time) 239 282 { … … 241 284 242 285 struct tm *tmTime = psTimeToTM(&time); 243 double year = (double)(1900 + tmTime->tm_year); 244 double T = year / 100.0; 245 double phi = +23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T; 246 double alphaP = 0.0; 247 double phiP = 0.0; 286 psF64 year = (psF64)(1900 + tmTime->tm_year); 287 psF64 T = year / 100.0; 288 psF64 alphaP = 0.0; 289 psF64 deltaP = DEG_TO_RAD(23.0) + 290 SEC_TO_RAD(27.0) + 291 MIN_TO_RAD(8.0) - 292 (SEC_TO_RAD(46.845) * T) - 293 (SEC_TO_RAD(0.0059) * T * T) + 294 (SEC_TO_RAD(0.00181) * T * T * T); 295 psF64 phiP = 0.0; 248 296 249 297 psFree(tmTime); 250 return (psSphereTransformAlloc(phi, alphaP, phiP)); 251 } 252 253 // XXX: SHould these be in radians, not degrees? 298 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 299 } 300 301 // XXX: Should these be in radians, not degrees? 302 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 303 // there is no algorithm for this in the ADD. 304 // XXX: This is bug 245 254 305 psSphereTransform* psSphereTransformICRSToGalatic(void) 255 306 { 256 return (psSphereTransformAlloc(62.6, 282.25, 33.0)); 257 } 258 259 // XXX: SHould these be in radians, not degrees? 307 psF64 alphaP = DEG_TO_RAD(-62.6); 308 psF64 deltaP = DEG_TO_RAD(33.0); 309 psF64 phiP = DEG_TO_RAD(282.25); 310 311 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 312 } 313 314 // XXX: Should these be in radians, not degrees? 315 // XXX: the ADD changed. This code no longer conforms to the old ADD. 260 316 psSphereTransform* psSphereTransformGalaticToICRS(void) 261 317 { 262 return (psSphereTransformAlloc(-62.6, 33.0, 282.25)); 318 psF64 alphaP = DEG_TO_RAD(282.85948); 319 psF64 deltaP = DEG_TO_RAD(62.87175); 320 psF64 phiP = DEG_TO_RAD(32.93192); 321 322 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 263 323 } 264 324 … … 273 333 PS_PTR_CHECK_NULL(projection, NULL); 274 334 275 float R = 0.0;276 float alpha = 0.0;335 // float R = 0.0; 336 // float alpha = 0.0; 277 337 psPlane* tmp = (psPlane* ) psAlloc(sizeof(psPlane)); 278 338 279 339 if (projection->type == PS_PROJ_TAN) { 280 R = PS_COT(coord->r) * (180.0 / M_PI); 281 tmp->x = R * sin(coord->d); 282 tmp->y = R * cos(coord->d); 340 tmp->x = cos(coord->r) * sin(coord->d) / sin(coord->r); 341 tmp->y = -cos(coord->r) * cos(coord->d) / sin(coord->r); 283 342 284 343 } else if (projection->type == PS_PROJ_SIN) { 285 R = cos(coord->r) * (180.0 / M_PI); 286 tmp->x = R * sin(coord->d); 287 tmp->y = R * cos(coord->d); 344 tmp->x = cos(coord->d) * sin(coord->d); 345 tmp->y = -cos(coord->d) * cos(coord->d); 288 346 289 347 } else if (projection->type == PS_PROJ_CAR) { … … 293 351 } else if (projection->type == PS_PROJ_MER) { 294 352 tmp->x = coord->d; 295 tmp->y = log(tan(45.0 + (0.5 * coord->r))) * 180.0 / M_PI; 296 353 tmp->y = log(tan(DEG_TO_RAD(45.0) + (0.5 * coord->r))); 297 354 } else if (projection->type == PS_PROJ_AIT) { 298 alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * 299 cos(0.5 * coord->d) * 0.5))); 300 301 tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d); 302 tmp->y = alpha * sin(coord->d); 355 psF64 tmpF64 = sqrt(0.5 * (1.0 + (cos(coord->r) * cos(0.5 * coord->d)))); 356 tmpF64 = 1.0 / tmpF64; 357 tmp->x = 2.0 * tmpF64 * cos(coord->r) * sin(0.5 * coord->d); 303 358 304 359 } else if (projection->type == PS_PROJ_PAR) { … … 337 392 338 393 if (projection->type == PS_PROJ_TAN) { 394 tmp->r = atan2(-coord->y, coord->x); 339 395 R = sqrt((coord->x * coord->x) + (coord->y * coord->y)); 340 tmp->d = atan2(-coord->y, coord->x); 341 tmp->r = atan(180.0 / (R * M_PI)); 396 tmp->d = atan(1.0 / R); 342 397 343 398 } else if (projection->type == PS_PROJ_SIN) { … … 434 489 435 490 if (unit == PS_ARCSEC) { 436 tmp->r = (tmp->r * 180.0 * 60.0 * 60.0) / M_PI;437 tmp->d = (tmp->d * 180.0 * 60.0 * 60.0) / M_PI;491 tmp->r = RAD_TO_SEC(tmp->r); 492 tmp->d = RAD_TO_SEC(tmp->d); 438 493 } else if (unit == PS_ARCMIN) { 439 tmp->r = (tmp->r * 180.0 * 60.0) / M_PI;440 tmp->d = (tmp->d * 180.0 * 60.0) / M_PI;494 tmp->r = RAD_TO_MIN(tmp->r); 495 tmp->d = RAD_TO_MIN(tmp->d); 441 496 } else if (unit == PS_DEGREE) { 442 tmp->r = (tmp->r * 180.0) / M_PI;443 tmp->d = (tmp->d * 180.0) / M_PI;497 tmp->r = RAD_TO_DEG(tmp->r); 498 tmp->d = RAD_TO_DEG(tmp->d); 444 499 } else if (unit == PS_RADIAN) {} 445 500 else { … … 480 535 psSphere* tmp; 481 536 psProjection proj; 482 doubletmpR = 0.0;483 doubletmpD = 0.0;537 psF64 tmpR = 0.0; 538 psF64 tmpD = 0.0; 484 539 485 540 if (mode == PS_LINEAR) { … … 495 550 tmp = psDeproject(&lin, &proj); 496 551 return (tmp); 497 498 552 } else if (mode == PS_SPHERICAL) { 499 553 if (unit == PS_ARCSEC) { 500 tmpR = (M_PI * offset->r) / (180.0 * 60.0 * 60.0);501 tmpD = (M_PI * offset->d) / (180.0 * 60.0 * 60.0);554 tmpR = SEC_TO_RAD(offset->r); 555 tmpD = SEC_TO_RAD(offset->d); 502 556 } else if (unit == PS_ARCMIN) { 503 tmpR = (M_PI * offset->r) / (180.0 * 60.0);504 tmpD = (M_PI * offset->d) / (180.0 * 60.0);557 tmpR = MIN_TO_RAD(offset->r); 558 tmpD = MIN_TO_RAD(offset->d); 505 559 } else if (unit == PS_DEGREE) { 506 tmpR = (M_PI * offset->r) / (180.0);507 tmpD = (M_PI * offset->d) / (180.0);560 tmpR = DEG_TO_RAD(offset->r); 561 tmpD = DEG_TO_RAD(offset->d); 508 562 } else if (unit == PS_RADIAN) { 509 563 tmpR = offset->r; … … 533 587 } 534 588 535 // XXX: What algorithm should be used? 589 590 /****************************************************************************** 591 psSpherePrecess(coords, fromTime, toTime): 592 593 XXX: What algorithm should be used? 594 XXX: Verify that this is correct. 595 XXX: Use static memory for tmpST. 596 *****************************************************************************/ 536 597 psSphere *psSpherePrecess(psSphere *coords, 537 598 const psTime *fromTime, 538 599 const psTime *toTime) 539 600 { 540 /* 541 psF64 fromMJD = fromTime->sec/86400.0 + fromTime->usec/86400000000.0 + 40587.0; 542 psF64 toMJD = toTime->sec/86400.0 + toTime->usec/86400000000.0 + 40587.0; 543 psF64 = (toMJD - fromMJD) / 36525.0; 544 */ 545 return(NULL); 546 } 547 601 psF64 fromMJD = fromTime->sec/86400.0 + 602 fromTime->usec/86400000000.0 + 603 40587.0; 604 psF64 toMJD = toTime->sec/86400.0 + 605 toTime->usec/86400000000.0 + 606 40587.0; 607 psF64 T = (toMJD - fromMJD) / 36525.0; 608 609 psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 610 (DEG_TO_RAD(0.0000839) * T * T) + 611 (DEG_TO_RAD(0.000005) * T * T * T)); 612 613 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 614 (DEG_TO_RAD(0.0001185) * T * T) - 615 (DEG_TO_RAD(0.0000116) * T * T * T); 616 617 psF64 phiP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 618 (DEG_TO_RAD(0.0003041) * T * T) + 619 (DEG_TO_RAD(0.0000051) * T * T * T)); 620 621 psSphereTransform *tmpST = psSphereTransformAlloc(alphaP, deltaP, phiP); 622 623 psSphere *out = psSphereTransformApply(NULL, tmpST, coords); 624 625 psFree(tmpST); 626 627 return(out); 628 } 629 -
trunk/psLib/src/astro/psCoord.h
r2600 r2635 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 2 21:12:51$12 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-06 19:49:36 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 107 107 typedef struct 108 108 { 109 double alphaP; ///< Longitude of the target system pole in the source system 109 110 double cosDeltaP; ///< Cosine of target pole latitude in the source system 110 111 double sinDeltaP; ///< Sine of target pole latitude in the source system 111 double alphaP; ///< Longitude of the target system pole in the source system112 112 double phiP; ///< Longitude of the ascending node in the target system 113 113 } -
trunk/psLib/src/astronomy/psCoord.c
r2602 r2635 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 3 19:43:43$12 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-06 19:49:36 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 /******************************************************************************/ 20 20 #include "psType.h" 21 #include "psImage.h"22 #include "psArray.h"23 #include "psList.h"24 21 #include "psCoord.h" 25 22 #include "psMemory.h" … … 35 32 36 33 #define PS_COT(X) (1.0 / atan(X)) 34 #define DEG_TO_RAD(DEGREES) ((DEGREES) * M_PI / 180.0) 35 #define MIN_TO_RAD(MINUTES) ((MINUTES) * M_PI / (180.0 * 60.0)) 36 #define SEC_TO_RAD(SECONDS) ((SECONDS) * M_PI / (180.0 * 60.0 * 60.0)) 37 #define RAD_TO_DEG(RADIANS) ((RADIANS) * 180 / M_PI) 38 #define RAD_TO_MIN(RADIANS) ((RADIANS) * 180 * 60.0 / M_PI) 39 #define RAD_TO_SEC(RADIANS) ((RADIANS) * 180 * 60.0 * 60.0 / M_PI) 37 40 38 41 /******************************************************************************/ … … 162 165 163 166 /****************************************************************************** 164 This function prototype has been modified since the SDRS. 165 *****************************************************************************/ 166 psSphereTransform* psSphereTransformAlloc(double alphaP, 167 double deltaP, 168 double phiP) 167 alpha is LONGITUDE 168 delta is LATITUDE 169 170 alphaP: Take the target pole in the source system; calculate its LONGITUDE 171 in the target system. That longitude is alphaP. 172 DeltaP: Take the target pole in the source system; calculate its LATITUDE 173 in the target system. That longitude is deltaP. 174 phiP: This is the LONGITUDE of the ascending node in the target system. 175 *****************************************************************************/ 176 psSphereTransform* psSphereTransformAlloc(psF64 alphaP, 177 psF64 deltaP, 178 psF64 phiP) 169 179 { 170 180 psSphereTransform* tmp = (psSphereTransform* ) psAlloc(sizeof(psSphereTransform)); … … 179 189 180 190 /****************************************************************************** 181 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 182 (r,d) in the sphere coordinates. 183 184 XXX: In Gene's email, there are different variables with similar names (y 185 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 186 are no typo's. 191 XXX: It's not clear if this code correctly implements what the equations in 192 the ADD imply. Bug 243 will, hopefully, decide that. 193 194 XXX: Once this code is verified, delete Gene's code. 187 195 *****************************************************************************/ 188 196 psSphere* psSphereTransformApply(psSphere* out, … … 193 201 PS_PTR_CHECK_NULL(coord, NULL); 194 202 195 double sinY = 0.0;196 double cosY = 0.0;197 double sinX = 0.0;198 double cosX = 0.0;199 double x = 0.0;200 double y = 0.0;201 double dx = 0.0;202 203 203 if (out == NULL) { 204 204 out = (psSphere* ) psAlloc(sizeof(psSphere)); 205 205 } 206 206 207 x = coord->r; 208 y = coord->d; 209 dx = x - transform->phiP; 210 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 211 sin(y) * transform->cosDeltaP; 212 cosY = sqrt(1.0 - sinY * sinY); 213 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 214 sin(y) * transform->sinDeltaP) / cos(y); 215 cosX = cos(y) * cos(dx) / cos(y); 216 217 out->r = atan2(sinX, cosX) + transform->alphaP; 218 out->d = atan2(sinY, cosY); 219 220 return (out); 221 } 222 207 psF64 alpha = coord->r; 208 psF64 delta = coord->d; 209 psF64 alphaMinusAlphaP = alpha - transform->alphaP; 210 211 psF64 eq55 = (sin(delta) * transform->cosDeltaP) - 212 (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP)); 213 214 psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) + 215 (sin(delta) * transform->sinDeltaP); 216 217 psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP); 218 219 psF64 theta = asin(eq55); 220 psF64 phi = atan2(eq56, eq57) + transform->alphaP; 221 222 out->r = phi; 223 out->d = theta; 224 225 return(out); 226 227 /* 228 This algorithm comes from an email from Gene. I assume (x,y) corresponds to 229 (r,d) in the sphere coordinates. 230 231 XXX: In Gene's email, there are different variables with similar names (y 232 and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that there 233 are no typo's. 234 235 psF64 sinY = 0.0; 236 psF64 cosY = 0.0; 237 psF64 sinX = 0.0; 238 psF64 cosX = 0.0; 239 psF64 x = 0.0; 240 psF64 y = 0.0; 241 psF64 dx = 0.0; 242 243 x = coord->r; 244 y = coord->d; 245 dx = x - transform->phiP; 246 sinY = cos(y) * sin(dx) * transform->sinDeltaP + 247 sin(y) * transform->cosDeltaP; 248 cosY = sqrt(1.0 - sinY * sinY); 249 sinX = (cos(y) * sin(dx) * transform->cosDeltaP - 250 sin(y) * transform->sinDeltaP) / cos(y); 251 cosX = cos(y) * cos(dx) / cos(y); 252 253 out->r = atan2(sinX, cosX) + transform->alphaP; 254 out->d = atan2(sinY, cosY); 255 */ 256 } 257 258 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 259 // there is no algorithm for this in the ADD. 260 // XXX: This is bug 244 223 261 psSphereTransform* psSphereTransformICRSToEcliptic(psTime time) 224 262 { … … 226 264 227 265 struct tm *tmTime = psTimeToTM(&time); 228 double year = (double)(1900 + tmTime->tm_year); 229 double T = year / 100.0; 230 double phi = -23.452294 + 0.013013 * T + 0.000001639 * T * T - 0.000000503 * T * T * T; 231 double alphaP = 0.0; 232 double phiP = 0.0; 266 psF64 year = (psF64)(1900 + tmTime->tm_year); 267 psF64 T = year / 100.0; 268 psF64 phi = DEG_TO_RAD(-23.452294) + 269 (DEG_TO_RAD(0.013013) * T) + 270 (DEG_TO_RAD(0.000001639) * T * T) - 271 (DEG_TO_RAD(0.000000503) * T * T * T); 272 psF64 alphaP = 0.0; 273 psF64 phiP = 0.0; 233 274 234 275 psFree(tmTime); … … 236 277 } 237 278 279 // XXX: the ADD changed. This code no longer conforms to the old ADD. 280 // XXX: Waiting for IfA to sepcify if T should include days/months/etc. 238 281 psSphereTransform* psSphereTransformEclipticToICRS(psTime time) 239 282 { … … 241 284 242 285 struct tm *tmTime = psTimeToTM(&time); 243 double year = (double)(1900 + tmTime->tm_year); 244 double T = year / 100.0; 245 double phi = +23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T; 246 double alphaP = 0.0; 247 double phiP = 0.0; 286 psF64 year = (psF64)(1900 + tmTime->tm_year); 287 psF64 T = year / 100.0; 288 psF64 alphaP = 0.0; 289 psF64 deltaP = DEG_TO_RAD(23.0) + 290 SEC_TO_RAD(27.0) + 291 MIN_TO_RAD(8.0) - 292 (SEC_TO_RAD(46.845) * T) - 293 (SEC_TO_RAD(0.0059) * T * T) + 294 (SEC_TO_RAD(0.00181) * T * T * T); 295 psF64 phiP = 0.0; 248 296 249 297 psFree(tmTime); 250 return (psSphereTransformAlloc(phi, alphaP, phiP)); 251 } 252 253 // XXX: SHould these be in radians, not degrees? 298 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 299 } 300 301 // XXX: Should these be in radians, not degrees? 302 // XXX: the ADD changed. This code no longer conforms to the ADD. In fact, 303 // there is no algorithm for this in the ADD. 304 // XXX: This is bug 245 254 305 psSphereTransform* psSphereTransformICRSToGalatic(void) 255 306 { 256 return (psSphereTransformAlloc(62.6, 282.25, 33.0)); 257 } 258 259 // XXX: SHould these be in radians, not degrees? 307 psF64 alphaP = DEG_TO_RAD(-62.6); 308 psF64 deltaP = DEG_TO_RAD(33.0); 309 psF64 phiP = DEG_TO_RAD(282.25); 310 311 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 312 } 313 314 // XXX: Should these be in radians, not degrees? 315 // XXX: the ADD changed. This code no longer conforms to the old ADD. 260 316 psSphereTransform* psSphereTransformGalaticToICRS(void) 261 317 { 262 return (psSphereTransformAlloc(-62.6, 33.0, 282.25)); 318 psF64 alphaP = DEG_TO_RAD(282.85948); 319 psF64 deltaP = DEG_TO_RAD(62.87175); 320 psF64 phiP = DEG_TO_RAD(32.93192); 321 322 return (psSphereTransformAlloc(alphaP, deltaP, phiP)); 263 323 } 264 324 … … 273 333 PS_PTR_CHECK_NULL(projection, NULL); 274 334 275 float R = 0.0;276 float alpha = 0.0;335 // float R = 0.0; 336 // float alpha = 0.0; 277 337 psPlane* tmp = (psPlane* ) psAlloc(sizeof(psPlane)); 278 338 279 339 if (projection->type == PS_PROJ_TAN) { 280 R = PS_COT(coord->r) * (180.0 / M_PI); 281 tmp->x = R * sin(coord->d); 282 tmp->y = R * cos(coord->d); 340 tmp->x = cos(coord->r) * sin(coord->d) / sin(coord->r); 341 tmp->y = -cos(coord->r) * cos(coord->d) / sin(coord->r); 283 342 284 343 } else if (projection->type == PS_PROJ_SIN) { 285 R = cos(coord->r) * (180.0 / M_PI); 286 tmp->x = R * sin(coord->d); 287 tmp->y = R * cos(coord->d); 344 tmp->x = cos(coord->d) * sin(coord->d); 345 tmp->y = -cos(coord->d) * cos(coord->d); 288 346 289 347 } else if (projection->type == PS_PROJ_CAR) { … … 293 351 } else if (projection->type == PS_PROJ_MER) { 294 352 tmp->x = coord->d; 295 tmp->y = log(tan(45.0 + (0.5 * coord->r))) * 180.0 / M_PI; 296 353 tmp->y = log(tan(DEG_TO_RAD(45.0) + (0.5 * coord->r))); 297 354 } else if (projection->type == PS_PROJ_AIT) { 298 alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * 299 cos(0.5 * coord->d) * 0.5))); 300 301 tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d); 302 tmp->y = alpha * sin(coord->d); 355 psF64 tmpF64 = sqrt(0.5 * (1.0 + (cos(coord->r) * cos(0.5 * coord->d)))); 356 tmpF64 = 1.0 / tmpF64; 357 tmp->x = 2.0 * tmpF64 * cos(coord->r) * sin(0.5 * coord->d); 303 358 304 359 } else if (projection->type == PS_PROJ_PAR) { … … 337 392 338 393 if (projection->type == PS_PROJ_TAN) { 394 tmp->r = atan2(-coord->y, coord->x); 339 395 R = sqrt((coord->x * coord->x) + (coord->y * coord->y)); 340 tmp->d = atan2(-coord->y, coord->x); 341 tmp->r = atan(180.0 / (R * M_PI)); 396 tmp->d = atan(1.0 / R); 342 397 343 398 } else if (projection->type == PS_PROJ_SIN) { … … 434 489 435 490 if (unit == PS_ARCSEC) { 436 tmp->r = (tmp->r * 180.0 * 60.0 * 60.0) / M_PI;437 tmp->d = (tmp->d * 180.0 * 60.0 * 60.0) / M_PI;491 tmp->r = RAD_TO_SEC(tmp->r); 492 tmp->d = RAD_TO_SEC(tmp->d); 438 493 } else if (unit == PS_ARCMIN) { 439 tmp->r = (tmp->r * 180.0 * 60.0) / M_PI;440 tmp->d = (tmp->d * 180.0 * 60.0) / M_PI;494 tmp->r = RAD_TO_MIN(tmp->r); 495 tmp->d = RAD_TO_MIN(tmp->d); 441 496 } else if (unit == PS_DEGREE) { 442 tmp->r = (tmp->r * 180.0) / M_PI;443 tmp->d = (tmp->d * 180.0) / M_PI;497 tmp->r = RAD_TO_DEG(tmp->r); 498 tmp->d = RAD_TO_DEG(tmp->d); 444 499 } else if (unit == PS_RADIAN) {} 445 500 else { … … 480 535 psSphere* tmp; 481 536 psProjection proj; 482 doubletmpR = 0.0;483 doubletmpD = 0.0;537 psF64 tmpR = 0.0; 538 psF64 tmpD = 0.0; 484 539 485 540 if (mode == PS_LINEAR) { … … 495 550 tmp = psDeproject(&lin, &proj); 496 551 return (tmp); 497 498 552 } else if (mode == PS_SPHERICAL) { 499 553 if (unit == PS_ARCSEC) { 500 tmpR = (M_PI * offset->r) / (180.0 * 60.0 * 60.0);501 tmpD = (M_PI * offset->d) / (180.0 * 60.0 * 60.0);554 tmpR = SEC_TO_RAD(offset->r); 555 tmpD = SEC_TO_RAD(offset->d); 502 556 } else if (unit == PS_ARCMIN) { 503 tmpR = (M_PI * offset->r) / (180.0 * 60.0);504 tmpD = (M_PI * offset->d) / (180.0 * 60.0);557 tmpR = MIN_TO_RAD(offset->r); 558 tmpD = MIN_TO_RAD(offset->d); 505 559 } else if (unit == PS_DEGREE) { 506 tmpR = (M_PI * offset->r) / (180.0);507 tmpD = (M_PI * offset->d) / (180.0);560 tmpR = DEG_TO_RAD(offset->r); 561 tmpD = DEG_TO_RAD(offset->d); 508 562 } else if (unit == PS_RADIAN) { 509 563 tmpR = offset->r; … … 533 587 } 534 588 535 // XXX: What algorithm should be used? 589 590 /****************************************************************************** 591 psSpherePrecess(coords, fromTime, toTime): 592 593 XXX: What algorithm should be used? 594 XXX: Verify that this is correct. 595 XXX: Use static memory for tmpST. 596 *****************************************************************************/ 536 597 psSphere *psSpherePrecess(psSphere *coords, 537 598 const psTime *fromTime, 538 599 const psTime *toTime) 539 600 { 540 /* 541 psF64 fromMJD = fromTime->sec/86400.0 + fromTime->usec/86400000000.0 + 40587.0; 542 psF64 toMJD = toTime->sec/86400.0 + toTime->usec/86400000000.0 + 40587.0; 543 psF64 = (toMJD - fromMJD) / 36525.0; 544 */ 545 return(NULL); 546 } 547 601 psF64 fromMJD = fromTime->sec/86400.0 + 602 fromTime->usec/86400000000.0 + 603 40587.0; 604 psF64 toMJD = toTime->sec/86400.0 + 605 toTime->usec/86400000000.0 + 606 40587.0; 607 psF64 T = (toMJD - fromMJD) / 36525.0; 608 609 psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 610 (DEG_TO_RAD(0.0000839) * T * T) + 611 (DEG_TO_RAD(0.000005) * T * T * T)); 612 613 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 614 (DEG_TO_RAD(0.0001185) * T * T) - 615 (DEG_TO_RAD(0.0000116) * T * T * T); 616 617 psF64 phiP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 618 (DEG_TO_RAD(0.0003041) * T * T) + 619 (DEG_TO_RAD(0.0000051) * T * T * T)); 620 621 psSphereTransform *tmpST = psSphereTransformAlloc(alphaP, deltaP, phiP); 622 623 psSphere *out = psSphereTransformApply(NULL, tmpST, coords); 624 625 psFree(tmpST); 626 627 return(out); 628 } 629 -
trunk/psLib/src/astronomy/psCoord.h
r2600 r2635 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-0 2 21:12:51$12 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-06 19:49:36 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 107 107 typedef struct 108 108 { 109 double alphaP; ///< Longitude of the target system pole in the source system 109 110 double cosDeltaP; ///< Cosine of target pole latitude in the source system 110 111 double sinDeltaP; ///< Sine of target pole latitude in the source system 111 double alphaP; ///< Longitude of the target system pole in the source system112 112 double phiP; ///< Longitude of the ascending node in the target system 113 113 } -
trunk/psLib/src/dataManip/psConstants.h
r2583 r2635 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-0 1 19:56:06 $8 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-06 19:49:36 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 *****************************************************************************/ 25 25 #define PS_ONE 1.0 26 27 28 26 29 27 /***************************************************************************** -
trunk/psLib/src/math/psConstants.h
r2583 r2635 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.4 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-0 1 19:56:06 $8 * @version $Revision: 1.42 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-06 19:49:36 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 *****************************************************************************/ 25 25 #define PS_ONE 1.0 26 27 28 26 29 27 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
