Changeset 2077 for trunk/psLib/src/astro/psCoord.c
- Timestamp:
- Oct 13, 2004, 9:40:42 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psCoord.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r2058 r2077 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10-1 2 20:53:02 $12 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-13 19:40:42 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 61 61 XXX: Verify this arc tan function. 62 62 XXX: macro 63 XXX: I don't think this arg() is correct. 63 64 *****************************************************************************/ 64 65 … … 66 67 float y) 67 68 { 68 if (x > 0) { 69 return (atan(y / x)); 70 } else if ((x == 0) && (y == 0)) { 71 return (0.5 * M_PI); 72 } else if ((x == 0) && (y == 0)) { 73 return (-0.5 * M_PI); 74 } else if ((x == 0) && (y == 0)) { 75 return (M_PI + atan(y / x)); 76 } else if ((x == 0) && (y == 0)) { 77 return (-M_PI + atan(y / x)); 78 } 79 80 psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y); 69 if (y!= 0.0) { 70 return(atan(y/x)); 71 } else { 72 return(0.5 * M_PI); 73 } 81 74 return (0.0); 75 /* 76 if (x > 0) { 77 return (atan(y / x)); 78 } else if ((x == 0) && (y == 0)) { 79 return (0.5 * M_PI); 80 } else if ((x == 0) && (y == 0)) { 81 return (-0.5 * M_PI); 82 } else if ((x == 0) && (y == 0)) { 83 return (M_PI + atan(y / x)); 84 } else if ((x == 0) && (y == 0)) { 85 return (-M_PI + atan(y / x)); 86 } 87 psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y); 88 */ 82 89 } 83 90 … … 92 99 out = (psPlane* ) psAlloc(sizeof(psPlane)); 93 100 } 94 out->x = transform->x->coeff[0][0] + 95 (transform->x->coeff[1][0] * coords->x) + 96 (transform->x->coeff[0][1] * coords->y); 97 98 out->y = transform->y->coeff[0][0] + 99 (transform->y->coeff[1][0] * coords->x) + 100 (transform->y->coeff[0][1] * coords->y); 101 101 out->x = psDPolynomial2DEval(coords->x, coords->y, transform->x); 102 out->y = psDPolynomial2DEval(coords->x, coords->y, transform->y); 102 103 return (out); 103 104 } … … 116 117 out = (psPlane* ) psAlloc(sizeof(psPlane)); 117 118 } 118 119 out->x = transform->x->coeff[0][0][0][0] + 120 (transform->x->coeff[1][0][0][0] * coords->x) + 121 (transform->x->coeff[0][1][0][0] * coords->y) + 122 (transform->x->coeff[0][0][1][0] * color) + 123 (transform->x->coeff[0][0][0][1] * magnitude); 124 125 out->y = transform->y->coeff[0][0][0][0] + 126 (transform->y->coeff[1][0][0][0] * coords->x) + 127 (transform->y->coeff[0][1][0][0] * coords->y) + 128 (transform->y->coeff[0][0][1][0] * color) + 129 (transform->y->coeff[0][0][0][1] * magnitude); 130 119 out->x = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->x); 120 out->y = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->y); 131 121 return (out); 132 122 } … … 196 186 double xo = 0.0; 197 187 188 psFree(tmTime); 198 189 return (psSphereTransformAlloc(phi, Xo, xo)); 199 190 } … … 208 199 double xo = 0.0; 209 200 201 psFree(tmTime); 210 202 return (psSphereTransformAlloc(phi, Xo, xo)); 211 203 } … … 251 243 252 244 } else if (projection->type == PS_PROJ_AIT) { 253 alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * cos(0.5 * coord->d) * 0.5))); 245 alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * 246 cos(0.5 * coord->d) * 0.5))); 254 247 255 248 tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d); … … 325 318 326 319 XXX: Do I need to somehow scale this projection? 320 321 XXX: Does PS_LINEAR mode make sense? The result must be returned in psSphere 322 regardless of the mode. 323 324 XXX: How to compound errors? 327 325 *****************************************************************************/ 328 326 psSphere* psSphereGetOffset(const psSphere* restrict position1, … … 351 349 return (tmp); 352 350 } else if (mode == PS_SPHERICAL) { 353 tmpR = position2->r - position1->r; 354 tmpD = position2->d - position1->d; 351 tmp = (psSphere* ) psAlloc(sizeof(psSphere)); 352 tmp->r = position2->r - position1->r; 353 tmp->d = position2->d - position1->d; 354 355 // XXX: Wrap these to an acceptable range. This assumes that all 356 // angles are in radians. 357 tmp->r = fmod(tmp->r, 2*M_PI); 358 tmp->d = fmod(tmp->d, 2*M_PI); 359 tmp->rErr = 0.0; 360 tmp->dErr = 0.0; 355 361 356 362 if (unit == PS_ARCSEC) { 357 tmp R = (tmpR* 180.0 * 60.0 * 60.0) / M_PI;358 tmp D = (tmpR* 180.0 * 60.0 * 60.0) / M_PI;363 tmp->r = (tmp->r * 180.0 * 60.0 * 60.0) / M_PI; 364 tmp->d = (tmp->d * 180.0 * 60.0 * 60.0) / M_PI; 359 365 } else if (unit == PS_ARCMIN) { 360 tmp R = (tmpR* 180.0 * 60.0) / M_PI;361 tmp D = (tmpR* 180.0 * 60.0) / M_PI;366 tmp->r = (tmp->r * 180.0 * 60.0) / M_PI; 367 tmp->d = (tmp->d * 180.0 * 60.0) / M_PI; 362 368 } else if (unit == PS_DEGREE) { 363 tmp R = (tmpR* 180.0) / M_PI;364 tmp D = (tmpR* 180.0) / M_PI;369 tmp->r = (tmp->r * 180.0) / M_PI; 370 tmp->d = (tmp->d * 180.0) / M_PI; 365 371 } else if (unit == PS_RADIAN) {} 366 372 else { … … 368 374 } 369 375 370 tmp = (psSphere* ) psAlloc(sizeof(psSphere));371 // XXX: Wrap these to an acceptable range. Is this correct?372 tmp->r = fmod(tmpR, 2*M_PI);373 tmp->d = fmod(tmpD, 2*M_PI);374 tmp->rErr = 0.0;375 tmp->dErr = 0.0;376 377 376 return (tmp); 378 377 } … … 388 387 389 388 XXX: I copied the algorithm from the ADD exactly. 389 390 XXX: Should we compound errors? 390 391 *****************************************************************************/ 391 392 … … 432 433 433 434 tmp = (psSphere* ) psAlloc(sizeof(psSphere)); 434 // XXX: Is this an acceptable way to wrap the angular output?435 435 tmp->r = position->r + tmpR; 436 436 tmp->r = fmod(tmp->r, 2.0*M_PI);
Note:
See TracChangeset
for help on using the changeset viewer.
