Changeset 1296 for trunk/psLib/src/astronomy/psCoord.c
- Timestamp:
- Jul 26, 2004, 7:28:05 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astronomy/psCoord.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psCoord.c
r1293 r1296 10 10 * @author George Gusciora, MHPCC 11 11 * 12 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-07-2 4 02:42:59$12 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-07-27 05:28:05 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include <float.h> 27 27 28 // This is the only function in this file which I understand. 28 29 psPlane *psPlaneTransformApply(psPlane *out, 29 30 const psPlaneTransform *transform, … … 72 73 73 74 74 psSphereTransform *psSphereTransformAlloc(double NPl on,75 double NPlat,76 double ZP)75 psSphereTransform *psSphereTransformAlloc(double NPlat, 76 double Xo, 77 double xo) 77 78 { 78 79 psSphereTransform *tmp = (psSphereTransform *) psAlloc(sizeof(psSphereTransform)); 79 80 80 tmp->sinNPlon = sin(NPlon); 81 tmp->cosNPlon = cos(NPlon); 82 tmp->sinNPlat = sin(NPlat); 83 tmp->cosNPlat = cos(NPlat); 84 tmp->sinZP = sin(ZP); 85 tmp->cosZP = cos(ZP); 81 tmp->sinPhi = sin(NPlat); 82 tmp->cosPhi = cos(NPlat); 83 tmp->Xo = Xo; 84 tmp->xo = xo; 86 85 87 86 return(tmp); 88 87 } 89 88 90 89 // I understand this one too. 91 90 void p_psSphereTransformFree(psSphereTransform *trans) 92 91 { … … 95 94 96 95 97 96 // XXX: I have no idea how this works. This algorithm comes from an email 97 // from Gene. I assume (x,y) corresponds to (r,d) in the sphere coordinates. 98 99 // XXX: In Gene's email, there are different variables with similar names 100 // (y and Y) and in the code, there's cos_y, cos_Y, and cos(y). Verify that 101 // there are no typo's. 98 102 99 103 psSphere *psSphereTransformApply(psSphere *out, … … 101 105 const psSphere *coord) 102 106 { 103 return(NULL); 104 } 105 106 107 double sinY = 0.0; 108 ; 109 double cosY = 0.0; 110 ; 111 double sinX = 0.0; 112 ; 113 double cosX = 0.0; 114 ; 115 double x = 0.0; 116 double y = 0.0; 117 double dx = 0.0; 118 119 if (out == NULL) { 120 out = (psSphere *) psAlloc(sizeof(psSphere)); 121 } 122 123 x = coord->r; 124 y = coord->d; 125 dx = x - transform->xo; 126 sinY = cos(y)*sin(dx)*transform->sinPhi + sin(y)*transform->cosPhi; 127 cosY = sqrt(1.0 - sinY*sinY); 128 sinX = (cos(y)*sin(dx)*transform->cosPhi - sin(y)*transform->sinPhi) / 129 cos(y); 130 cosX = cos(y)*cos(dx) / cos(y); 131 132 out->r = atan2(sinX, cosX) + transform->Xo; 133 out->d = atan2(sinY, cosY); 134 135 return(out); 136 } 137 138 // XXX: Add a date argument to determine the correct year. 107 139 psSphereTransform *psSphereTransformICRStoEcliptic(void) 108 140 { 109 // sla_EQECL(); 110 return(NULL); 111 } 112 141 double year = 2004.0; 142 double T = year / 100.0; 143 double phi = -23.452294 + 0.013013*T + 0.000001639*T*T - 0.000000503*T*T*T; 144 double Xo = 0.0; 145 double xo = 0.0; 146 147 return(psSphereTransformAlloc(phi, Xo, xo)); 148 } 149 150 // XXX: Add a date argument to determine the correct year. 113 151 psSphereTransform *psSphereTransformEcliptictoICRS(void) 114 152 { 115 // sla_ECLEQ(); 116 return(NULL); 153 double year = 2004.0; 154 double T = year / 100.0; 155 double phi = +23.452294 - 0.013013*T - 0.000001639*T*T + 0.000000503*T*T*T; 156 double Xo = 0.0; 157 double xo = 0.0; 158 159 return(psSphereTransformAlloc(phi, Xo, xo)); 117 160 } 118 161 119 162 psSphereTransform *psSphereTransformICRStoGalatic(void) 120 163 { 121 // sla_EQGAL(); 122 return(NULL); 164 return(psSphereTransformAlloc(62.6, 282.25, 33.0)); 123 165 } 124 166 125 167 psSphereTransform *psSphereTransformGalatictoICRS(void) 126 168 { 127 // sla_GALEQL(); 128 return(NULL); 169 return(psSphereTransformAlloc(-62.6, 33.0, 282.25)); 129 170 } 130 171 … … 135 176 } 136 177 178 // This is some kind of arc tan function. 137 179 float arg(float x, float y) 138 180 { … … 153 195 } 154 196 155 197 // XXX: Waiting for the definition of the PS_PROJ_PAR projection. 198 // XXX: Waiting for the definition of the PS_PROJ_GLS projection. 156 199 psPlane *psProject(const psSphere *coord, 157 200 const psProjection *projection) … … 190 233 191 234 } else if (projection->type == PS_PROJ_GLS) { 192 psAbort(__func__, "The projection type PS_PROJ_GL Gis undefined.\n");235 psAbort(__func__, "The projection type PS_PROJ_GLS is undefined.\n"); 193 236 } 194 237 … … 196 239 } 197 240 241 // XXX: Waiting for the definition of the PS_PROJ_PAR projection. 242 // XXX: Waiting for the definition of the PS_PROJ_GLS projection. 198 243 psSphere *psDeproject(const psPlane *coord, 199 244 const psProjection *projection) … … 248 293 psSphereOffsetUnit unit) 249 294 { 250 psAbort(__func__, "This function has not be dedfined.\n"); 295 // psPlane lin; 296 psSphere *tmp; 297 // psProjection proj; 298 double tmpR = 0.0; 299 double tmpD = 0.0; 300 301 if (mode == PS_LINEAR) { 302 // XXX: I have no idea how to construct this. 303 return(NULL); 304 } else if (mode == PS_SPHERICAL) { 305 tmpR = position2->r - position1->r; 306 tmpD = position2->d - position1->d; 307 308 if (unit == PS_ARCSEC) { 309 tmpR = (tmpR * 180.0 * 60.0 * 60.0) / M_PI; 310 tmpD = (tmpR * 180.0 * 60.0 * 60.0) / M_PI; 311 } else if (unit == PS_ARCMIN) { 312 tmpR = (tmpR * 180.0 * 60.0) / M_PI; 313 tmpD = (tmpR * 180.0 * 60.0) / M_PI; 314 } else if (unit == PS_DEGREE) { 315 tmpR = (tmpR * 180.0) / M_PI; 316 tmpD = (tmpR * 180.0) / M_PI; 317 } else if (unit == PS_RADIAN) {} 318 else { 319 psAbort(__func__, "Unknow offset unit: 0x%x\n", unit); 320 } 321 322 tmp = (psSphere *) psAlloc(sizeof(psSphere)); 323 tmp->r = tmpR; 324 tmp->d = tmpD; 325 tmp->rErr = 0.0; 326 tmp->dErr = 0.0; 327 // XXX: Do we need to wrap these to an acceptable range? 328 return(tmp); 329 } 330 psAbort(__func__, "Unrecognized offset mode\n"); 251 331 return(NULL); 252 332 } 253 333 254 334 255 // XXX: I copied the algorithm from the ADD exactly. Arguments mode and unit 256 // are ignored. 335 // XXX: I copied the algorithm from the ADD exactly. 257 336 psSphere *psSphereSetOffset(const psSphere *restrict position, 258 337 const psSphere *restrict offset, … … 263 342 psSphere *tmp; 264 343 psProjection proj; 344 double tmpR = 0.0; 345 double tmpD = 0.0; 265 346 266 347 if (mode == PS_LINEAR) { 267 348 proj.R = position->r; 268 349 proj.D = position->d; 269 proj.Xs = 0.0;270 proj.Ys = 0.0;350 proj.Xs = 1.0; 351 proj.Ys = 1.0; 271 352 proj.type = PS_PROJ_TAN; 272 353 … … 276 357 tmp = psDeproject(&lin, &proj); 277 358 return(tmp); 359 278 360 } else if (mode == PS_SPHERICAL) { 279 psAbort(__func__, "Sperical offset modes are not defined.\n"); 361 if (unit == PS_ARCSEC) { 362 tmpR = (M_PI * offset->r) / (180.0 * 60.0 * 60.0); 363 tmpD = (M_PI * offset->d) / (180.0 * 60.0 * 60.0); 364 } else if (unit == PS_ARCMIN) { 365 tmpR = (M_PI * offset->r) / (180.0 * 60.0); 366 tmpD = (M_PI * offset->d) / (180.0 * 60.0); 367 } else if (unit == PS_DEGREE) { 368 tmpR = (M_PI * offset->r) / (180.0); 369 tmpD = (M_PI * offset->d) / (180.0); 370 } else if (unit == PS_RADIAN) { 371 tmpR = offset->r; 372 tmpD = offset->d; 373 } else { 374 psAbort(__func__, "Unknow offset unit: 0x%x\n", unit); 375 } 376 377 tmp = (psSphere *) psAlloc(sizeof(psSphere)); 378 tmp->r = position->r + tmpR; 379 tmp->r = position->d + tmpD; 380 tmp->rErr = 0.0; 381 tmp->dErr = 0.0; 382 383 // XXX: wrap tmp->r and tmp->d to the allowed range (-PI to PI) 384 // and (0 to 2*PI). 385 return(tmp); 280 386 } 281 387 psAbort(__func__, "Unrecognized offset mode\n");
Note:
See TracChangeset
for help on using the changeset viewer.
