Changeset 1407 for trunk/psLib/src/astronomy/psCoord.c
- Timestamp:
- Aug 6, 2004, 2:06:06 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astronomy/psCoord.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psCoord.c
r1406 r1407 1 1 2 /** @file psCoord.c 2 3 * … … 10 11 * @author George Gusciora, MHPCC 11 12 * 12 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08-0 6 22:34:05$13 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-08-07 00:06:06 $ 14 15 * 15 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 28 #include <float.h> 28 29 29 static float cot( float x);30 static float arg( float x, float y);30 static float cot(float x); 31 static float arg(float x, float y); 31 32 32 33 // This is the only function in this file which I understand. 33 psPlane *psPlaneTransformApply( psPlane *out, 34 const psPlaneTransform *transform, 35 const psPlane *coords ) 36 { 37 if ( out == NULL ) { 38 out = ( psPlane * ) psAlloc( sizeof( psPlane ) ); 39 } 40 out->x = transform->x->coeff[ 0 ][ 0 ] + 41 ( transform->x->coeff[ 1 ][ 0 ] * coords->x ) + 42 ( transform->x->coeff[ 0 ][ 1 ] * coords->y ); 43 44 out->y = transform->y->coeff[ 0 ][ 0 ] + 45 ( transform->y->coeff[ 1 ][ 0 ] * coords->x ) + 46 ( transform->y->coeff[ 0 ][ 1 ] * coords->y ); 47 48 return ( out ); 49 } 50 34 psPlane *psPlaneTransformApply(psPlane * out, const psPlaneTransform * transform, const psPlane * coords) 35 { 36 if (out == NULL) { 37 out = (psPlane *) psAlloc(sizeof(psPlane)); 38 } 39 out->x = transform->x->coeff[0][0] + 40 (transform->x->coeff[1][0] * coords->x) + (transform->x->coeff[0][1] * coords->y); 41 42 out->y = transform->y->coeff[0][0] + 43 (transform->y->coeff[1][0] * coords->x) + (transform->y->coeff[0][1] * coords->y); 44 45 return (out); 46 } 51 47 52 48 // This transformation takes into account parameters beyond an objects 53 49 // spatial coordinates: term3 and term4. 54 psPlane *psPlaneDistortApply( psPlane *out, 55 const psPlaneDistort *transform, 56 const psPlane *coords, 57 float term3, 58 float term4 ) 59 { 60 if ( out == NULL ) { 61 out = ( psPlane * ) psAlloc( sizeof( psPlane ) ); 62 } 63 64 out->x = transform->x->coeff[ 0 ][ 0 ][ 0 ][ 0 ] + 65 ( transform->x->coeff[ 1 ][ 0 ][ 0 ][ 0 ] * coords->x ) + 66 ( transform->x->coeff[ 0 ][ 1 ][ 0 ][ 0 ] * coords->y ) + 67 ( transform->x->coeff[ 0 ][ 0 ][ 1 ][ 0 ] * term3 ) + 68 ( transform->x->coeff[ 0 ][ 0 ][ 0 ][ 1 ] * term4 ); 69 70 out->y = transform->y->coeff[ 0 ][ 0 ][ 0 ][ 0 ] + 71 ( transform->y->coeff[ 1 ][ 0 ][ 0 ][ 0 ] * coords->x ) + 72 ( transform->y->coeff[ 0 ][ 1 ][ 0 ][ 0 ] * coords->y ) + 73 ( transform->y->coeff[ 0 ][ 0 ][ 1 ][ 0 ] * term3 ) + 74 ( transform->y->coeff[ 0 ][ 0 ][ 0 ][ 1 ] * term4 ); 75 76 return ( out ); 77 } 78 50 psPlane *psPlaneDistortApply(psPlane * out, 51 const psPlaneDistort * transform, 52 const psPlane * coords, float term3, float term4) 53 { 54 if (out == NULL) { 55 out = (psPlane *) psAlloc(sizeof(psPlane)); 56 } 57 58 out->x = transform->x->coeff[0][0][0][0] + 59 (transform->x->coeff[1][0][0][0] * coords->x) + 60 (transform->x->coeff[0][1][0][0] * coords->y) + 61 (transform->x->coeff[0][0][1][0] * term3) + (transform->x->coeff[0][0][0][1] * term4); 62 63 out->y = transform->y->coeff[0][0][0][0] + 64 (transform->y->coeff[1][0][0][0] * coords->x) + 65 (transform->y->coeff[0][1][0][0] * coords->y) + 66 (transform->y->coeff[0][0][1][0] * term3) + (transform->y->coeff[0][0][0][1] * term4); 67 68 return (out); 69 } 79 70 80 71 // This function prototype has been modified since the SDRS. 81 psSphereTransform *psSphereTransformAlloc( double NPlat, 82 double Xo, 83 double xo ) 84 { 85 psSphereTransform * tmp = ( psSphereTransform * ) psAlloc( sizeof( psSphereTransform ) ); 86 87 tmp->sinPhi = sin( NPlat ); 88 tmp->cosPhi = cos( NPlat ); 72 psSphereTransform *psSphereTransformAlloc(double NPlat, double Xo, double xo) 73 { 74 psSphereTransform *tmp = (psSphereTransform *) psAlloc(sizeof(psSphereTransform)); 75 76 tmp->sinPhi = sin(NPlat); 77 tmp->cosPhi = cos(NPlat); 89 78 tmp->Xo = Xo; 90 79 tmp->xo = xo; 91 80 92 return ( tmp);81 return (tmp); 93 82 } 94 83 … … 100 89 // there are no typo's. 101 90 102 psSphere *psSphereTransformApply( psSphere *out, 103 const psSphereTransform *transform, 104 const psSphere *coord ) 91 psSphere *psSphereTransformApply(psSphere * out, const psSphereTransform * transform, const psSphere * coord) 105 92 { 106 93 double sinY = 0.0; … … 112 99 double dx = 0.0; 113 100 114 if ( out == NULL) {115 out = ( psSphere * ) psAlloc( sizeof( psSphere ));101 if (out == NULL) { 102 out = (psSphere *) psAlloc(sizeof(psSphere)); 116 103 } 117 104 … … 119 106 y = coord->d; 120 107 dx = x - transform->xo; 121 sinY = cos( y ) * sin( dx ) * transform->sinPhi + sin( y ) * transform->cosPhi; 122 cosY = sqrt( 1.0 - sinY * sinY ); 123 sinX = ( cos( y ) * sin( dx ) * transform->cosPhi - sin( y ) * transform->sinPhi ) / 124 cos( y ); 125 cosX = cos( y ) * cos( dx ) / cos( y ); 126 127 out->r = atan2( sinX, cosX ) + transform->Xo; 128 out->d = atan2( sinY, cosY ); 129 130 return ( out ); 131 } 132 133 psSphereTransform *psSphereTransformICRStoEcliptic( psTime time ) 134 { 135 struct tm * tmTime = psTimeToTM( time ); 136 double year = ( double ) ( 1900 + tmTime->tm_year ); 108 sinY = cos(y) * sin(dx) * transform->sinPhi + sin(y) * transform->cosPhi; 109 cosY = sqrt(1.0 - sinY * sinY); 110 sinX = (cos(y) * sin(dx) * transform->cosPhi - sin(y) * transform->sinPhi) / cos(y); 111 cosX = cos(y) * cos(dx) / cos(y); 112 113 out->r = atan2(sinX, cosX) + transform->Xo; 114 out->d = atan2(sinY, cosY); 115 116 return (out); 117 } 118 119 psSphereTransform *psSphereTransformICRStoEcliptic(psTime time) 120 { 121 struct tm *tmTime = psTimeToTM(time); 122 double year = (double)(1900 + tmTime->tm_year); 137 123 double T = year / 100.0; 138 124 double phi = -23.452294 + 0.013013 * T + 0.000001639 * T * T - 0.000000503 * T * T * T; … … 140 126 double xo = 0.0; 141 127 142 return ( psSphereTransformAlloc( phi, Xo, xo ));143 } 144 145 psSphereTransform *psSphereTransformEcliptictoICRS( psTime time)146 { 147 struct tm * tmTime = psTimeToTM( time);148 double year = ( double ) ( 1900 + tmTime->tm_year);128 return (psSphereTransformAlloc(phi, Xo, xo)); 129 } 130 131 psSphereTransform *psSphereTransformEcliptictoICRS(psTime time) 132 { 133 struct tm *tmTime = psTimeToTM(time); 134 double year = (double)(1900 + tmTime->tm_year); 149 135 double T = year / 100.0; 150 double phi = + 23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T;136 double phi = +23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T; 151 137 double Xo = 0.0; 152 138 double xo = 0.0; 153 139 154 return ( psSphereTransformAlloc( phi, Xo, xo ));155 } 156 157 psSphereTransform *psSphereTransformICRStoGalatic( void)158 { 159 return ( psSphereTransformAlloc( 62.6, 282.25, 33.0 ));160 } 161 162 psSphereTransform *psSphereTransformGalatictoICRS( void)163 { 164 return ( psSphereTransformAlloc( -62.6, 33.0, 282.25 ));140 return (psSphereTransformAlloc(phi, Xo, xo)); 141 } 142 143 psSphereTransform *psSphereTransformICRStoGalatic(void) 144 { 145 return (psSphereTransformAlloc(62.6, 282.25, 33.0)); 146 } 147 148 psSphereTransform *psSphereTransformGalatictoICRS(void) 149 { 150 return (psSphereTransformAlloc(-62.6, 33.0, 282.25)); 165 151 } 166 152 167 153 // XXX: Is this the correct way to calculate this? 168 float cot( float x)169 { 170 return ( 1.0 / atan( x ));154 float cot(float x) 155 { 156 return (1.0 / atan(x)); 171 157 } 172 158 173 159 // This is some kind of arc tan function. 174 float arg( float x, float y ) 175 { 176 if ( x > 0 ) { 177 return ( atan( y / x ) ); 178 } else 179 if ( ( x == 0 ) && ( y == 0 ) ) { 180 return ( 0.5 * M_PI ); 181 } else 182 if ( ( x == 0 ) && ( y == 0 ) ) { 183 return ( -0.5 * M_PI ); 184 } else 185 if ( ( x == 0 ) && ( y == 0 ) ) { 186 return ( M_PI + atan( y / x ) ); 187 } else 188 if ( ( x == 0 ) && ( y == 0 ) ) { 189 return ( -M_PI + atan( y / x ) ); 190 } 191 192 psAbort( __func__, "Unacceptable range for (arg(%f, %f).\n", x, y ); 193 return ( 0.0 ); 160 float arg(float x, float y) 161 { 162 if (x > 0) { 163 return (atan(y / x)); 164 } else if ((x == 0) && (y == 0)) { 165 return (0.5 * M_PI); 166 } else if ((x == 0) && (y == 0)) { 167 return (-0.5 * M_PI); 168 } else if ((x == 0) && (y == 0)) { 169 return (M_PI + atan(y / x)); 170 } else if ((x == 0) && (y == 0)) { 171 return (-M_PI + atan(y / x)); 172 } 173 174 psAbort(__func__, "Unacceptable range for (arg(%f, %f).\n", x, y); 175 return (0.0); 194 176 } 195 177 196 178 // XXX: Waiting for the definition of the PS_PROJ_PAR projection. 197 179 // XXX: Waiting for the definition of the PS_PROJ_GLS projection. 198 psPlane *psProject( const psSphere *coord, 199 const psProjection *projection ) 180 psPlane *psProject(const psSphere * coord, const psProjection * projection) 200 181 { 201 182 float R = 0.0; 202 183 float alpha = 0.0; 203 psPlane *tmp = ( psPlane * ) psAlloc( sizeof( psPlane ) ); 204 205 if ( projection->type == PS_PROJ_TAN ) { 206 R = cot( coord->r ) * ( 180.0 / M_PI ); 207 tmp->x = R * sin( coord->d ); 208 tmp->y = R * cos( coord->d ); 209 210 } else 211 if ( projection->type == PS_PROJ_SIN ) { 212 R = cos( coord->r ) * ( 180.0 / M_PI ); 213 tmp->x = R * sin( coord->d ); 214 tmp->y = R * cos( coord->d ); 215 216 } else 217 if ( projection->type == PS_PROJ_CAR ) { 218 tmp->x = coord->d; 219 tmp->y = coord->r; 220 221 } else 222 if ( projection->type == PS_PROJ_MER ) { 223 tmp->x = coord->d; 224 tmp->y = log( tan( 45.0 + ( 0.5 * coord->r ) ) ) * 180.0 / M_PI; 225 226 } else 227 if ( projection->type == PS_PROJ_AIT ) { 228 alpha = 1.0 / ( ( 180.0 / M_PI ) * 229 sqrt( 1.0 + ( cos( coord->r ) * cos( 0.5 * coord->d ) * 0.5 ) ) ); 230 231 tmp->x = 2.0 * alpha * cos( coord->r ) * sin( 0.5 * coord->d ); 232 tmp->y = alpha * sin( coord->d ); 233 234 } else 235 if ( projection->type == PS_PROJ_PAR ) { 236 psAbort( __func__, "The projection type PS_PROJ_PAR is undefined.\n" ); 237 238 } else 239 if ( projection->type == PS_PROJ_GLS ) { 240 psAbort( __func__, "The projection type PS_PROJ_GLS is undefined.\n" ); 241 } 242 243 return ( tmp ); 184 psPlane *tmp = (psPlane *) psAlloc(sizeof(psPlane)); 185 186 if (projection->type == PS_PROJ_TAN) { 187 R = cot(coord->r) * (180.0 / M_PI); 188 tmp->x = R * sin(coord->d); 189 tmp->y = R * cos(coord->d); 190 191 } else if (projection->type == PS_PROJ_SIN) { 192 R = cos(coord->r) * (180.0 / M_PI); 193 tmp->x = R * sin(coord->d); 194 tmp->y = R * cos(coord->d); 195 196 } else if (projection->type == PS_PROJ_CAR) { 197 tmp->x = coord->d; 198 tmp->y = coord->r; 199 200 } else if (projection->type == PS_PROJ_MER) { 201 tmp->x = coord->d; 202 tmp->y = log(tan(45.0 + (0.5 * coord->r))) * 180.0 / M_PI; 203 204 } else if (projection->type == PS_PROJ_AIT) { 205 alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * cos(0.5 * coord->d) * 0.5))); 206 207 tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d); 208 tmp->y = alpha * sin(coord->d); 209 210 } else if (projection->type == PS_PROJ_PAR) { 211 psAbort(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 212 213 } else if (projection->type == PS_PROJ_GLS) { 214 psAbort(__func__, "The projection type PS_PROJ_GLS is undefined.\n"); 215 } 216 217 return (tmp); 244 218 } 245 219 246 220 // XXX: Waiting for the definition of the PS_PROJ_PAR projection. 247 221 // XXX: Waiting for the definition of the PS_PROJ_GLS projection. 248 psSphere *psDeproject( const psPlane *coord, 249 const psProjection *projection ) 222 psSphere *psDeproject(const psPlane * coord, const psProjection * projection) 250 223 { 251 224 float R = 0.0; … … 253 226 float chu1 = 0.0; 254 227 float chu2 = 0.0; 255 psSphere *tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) ); 256 257 if ( projection->type == PS_PROJ_TAN ) { 258 R = sqrt( ( coord->x * coord->x ) + ( coord->y * coord->y ) ); 259 tmp->d = arg( -coord->y, coord->x ); 260 tmp->r = atan( 180.0 / ( R * M_PI ) ); 261 262 } else 263 if ( projection->type == PS_PROJ_SIN ) { 264 R = sqrt( ( coord->x * coord->x ) + ( coord->y * coord->y ) ); 265 tmp->d = arg( -coord->y, coord->x ); 266 tmp->r = acos( ( R * M_PI ) / 180.0 ); 267 268 } else 269 if ( projection->type == PS_PROJ_CAR ) { 270 tmp->d = coord->x; 271 tmp->r = coord->y; 272 273 } else 274 if ( projection->type == PS_PROJ_MER ) { 275 tmp->d = coord->x; 276 tmp->r = ( 2.0 * atan( exp( ( coord->y * M_PI / 180.0 ) ) ) ) - 180.0; 277 278 } else 279 if ( projection->type == PS_PROJ_AIT ) { 280 chu1 = ( coord->x * M_PI ) / 720.0; 281 chu1 *= chu1; 282 chu2 = ( coord->y * M_PI ) / 360.0; 283 chu2 *= chu2; 284 chu = sqrt( 1.0 - chu1 - chu2 ); 285 tmp->d = 2.0 * arg( ( 2.0 * chu * chu ) - 1.0, 286 ( coord->x * chu * M_PI ) / 360.0 ); 287 tmp->r = asin( ( coord->y * chu * M_PI ) / 180.0 ); 288 289 } else 290 if ( projection->type == PS_PROJ_PAR ) { 291 psAbort( __func__, "The projection type PS_PROJ_PAR is undefined.\n" ); 292 293 } else 294 if ( projection->type == PS_PROJ_GLS ) { 295 psAbort( __func__, "The projection type PS_PROJ_GLG is undefined.\n" ); 296 } 297 298 return ( tmp ); 228 psSphere *tmp = (psSphere *) psAlloc(sizeof(psSphere)); 229 230 if (projection->type == PS_PROJ_TAN) { 231 R = sqrt((coord->x * coord->x) + (coord->y * coord->y)); 232 tmp->d = arg(-coord->y, coord->x); 233 tmp->r = atan(180.0 / (R * M_PI)); 234 235 } else if (projection->type == PS_PROJ_SIN) { 236 R = sqrt((coord->x * coord->x) + (coord->y * coord->y)); 237 tmp->d = arg(-coord->y, coord->x); 238 tmp->r = acos((R * M_PI) / 180.0); 239 240 } else if (projection->type == PS_PROJ_CAR) { 241 tmp->d = coord->x; 242 tmp->r = coord->y; 243 244 } else if (projection->type == PS_PROJ_MER) { 245 tmp->d = coord->x; 246 tmp->r = (2.0 * atan(exp((coord->y * M_PI / 180.0)))) - 180.0; 247 248 } else if (projection->type == PS_PROJ_AIT) { 249 chu1 = (coord->x * M_PI) / 720.0; 250 chu1 *= chu1; 251 chu2 = (coord->y * M_PI) / 360.0; 252 chu2 *= chu2; 253 chu = sqrt(1.0 - chu1 - chu2); 254 tmp->d = 2.0 * arg((2.0 * chu * chu) - 1.0, (coord->x * chu * M_PI) / 360.0); 255 tmp->r = asin((coord->y * chu * M_PI) / 180.0); 256 257 } else if (projection->type == PS_PROJ_PAR) { 258 psAbort(__func__, "The projection type PS_PROJ_PAR is undefined.\n"); 259 260 } else if (projection->type == PS_PROJ_GLS) { 261 psAbort(__func__, "The projection type PS_PROJ_GLG is undefined.\n"); 262 } 263 264 return (tmp); 299 265 } 300 266 301 267 // XXX: Do I need to check for unacceptable transformation parameters? 302 268 // Maybe, if the points are on the North/South Pole, etc? 303 psSphere *psSphereGetOffset( const psSphere *restrict position1, 304 const psSphere *restrict position2, 305 psSphereOffsetMode mode, 306 psSphereOffsetUnit unit ) 307 { 308 // psPlane *lin; 269 psSphere *psSphereGetOffset(const psSphere * restrict position1, 270 const psSphere * restrict position2, 271 psSphereOffsetMode mode, psSphereOffsetUnit unit) 272 { 273 // psPlane *lin; 309 274 psProjection proj; 310 275 psSphere *tmp; … … 312 277 double tmpD = 0.0; 313 278 314 if ( mode == PS_LINEAR) {279 if (mode == PS_LINEAR) { 315 280 // XXX: I have no idea how to construct this. Maybe project both 316 281 // sperical positions onto the plane, set the origin at one of the … … 318 283 319 284 // XXX: Do I need to somehow scale this projection? 320 // project position1? Will it project to (0.0, 0.0)?285 // project position1? Will it project to (0.0, 0.0)? 321 286 proj.R = position1->r; 322 287 proj.D = position1->d; … … 325 290 proj.type = PS_PROJ_TAN; 326 291 327 // lin = psProject(position2, proj);328 // tmp = psDeproject(lin, proj);292 // lin = psProject(position2, proj); 293 // tmp = psDeproject(lin, proj); 329 294 330 295 // XXX: Do we need to convert units in tmp? 331 return ( tmp ); 332 } else 333 if ( mode == PS_SPHERICAL ) { 334 tmpR = position2->r - position1->r; 335 tmpD = position2->d - position1->d; 336 337 if ( unit == PS_ARCSEC ) { 338 tmpR = ( tmpR * 180.0 * 60.0 * 60.0 ) / M_PI; 339 tmpD = ( tmpR * 180.0 * 60.0 * 60.0 ) / M_PI; 340 } else 341 if ( unit == PS_ARCMIN ) { 342 tmpR = ( tmpR * 180.0 * 60.0 ) / M_PI; 343 tmpD = ( tmpR * 180.0 * 60.0 ) / M_PI; 344 } else 345 if ( unit == PS_DEGREE ) { 346 tmpR = ( tmpR * 180.0 ) / M_PI; 347 tmpD = ( tmpR * 180.0 ) / M_PI; 348 } else 349 if ( unit == PS_RADIAN ) {} 350 else { 351 psAbort( __func__, "Unknown offset unit: 0x%x\n", unit ); 352 } 353 354 tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) ); 355 tmp->r = tmpR; 356 tmp->d = tmpD; 357 tmp->rErr = 0.0; 358 tmp->dErr = 0.0; 359 // XXX: Do we need to wrap these to an acceptable range? 360 return ( tmp ); 296 return (tmp); 297 } else if (mode == PS_SPHERICAL) { 298 tmpR = position2->r - position1->r; 299 tmpD = position2->d - position1->d; 300 301 if (unit == PS_ARCSEC) { 302 tmpR = (tmpR * 180.0 * 60.0 * 60.0) / M_PI; 303 tmpD = (tmpR * 180.0 * 60.0 * 60.0) / M_PI; 304 } else if (unit == PS_ARCMIN) { 305 tmpR = (tmpR * 180.0 * 60.0) / M_PI; 306 tmpD = (tmpR * 180.0 * 60.0) / M_PI; 307 } else if (unit == PS_DEGREE) { 308 tmpR = (tmpR * 180.0) / M_PI; 309 tmpD = (tmpR * 180.0) / M_PI; 310 } else if (unit == PS_RADIAN) {} 311 else { 312 psAbort(__func__, "Unknown offset unit: 0x%x\n", unit); 361 313 } 362 psAbort( __func__, "Unrecognized offset mode\n" ); 363 return ( NULL ); 364 } 365 314 315 tmp = (psSphere *) psAlloc(sizeof(psSphere)); 316 tmp->r = tmpR; 317 tmp->d = tmpD; 318 tmp->rErr = 0.0; 319 tmp->dErr = 0.0; 320 // XXX: Do we need to wrap these to an acceptable range? 321 return (tmp); 322 } 323 psAbort(__func__, "Unrecognized offset mode\n"); 324 return (NULL); 325 } 366 326 367 327 // XXX: Do I need to check for unacceptable transformation parameters? 368 328 // Maybe, if the points are on the North/South Pole, etc? 369 329 // XXX: I copied the algorithm from the ADD exactly. 370 psSphere *psSphereSetOffset( const psSphere *restrict position, 371 const psSphere *restrict offset, 372 psSphereOffsetMode mode, 373 psSphereOffsetUnit unit ) 330 psSphere *psSphereSetOffset(const psSphere * restrict position, 331 const psSphere * restrict offset, 332 psSphereOffsetMode mode, psSphereOffsetUnit unit) 374 333 { 375 334 psPlane lin; … … 379 338 double tmpD = 0.0; 380 339 381 if ( mode == PS_LINEAR) {340 if (mode == PS_LINEAR) { 382 341 proj.R = position->r; 383 342 proj.D = position->d; … … 389 348 lin.y = offset->d; 390 349 391 tmp = psDeproject( &lin, &proj ); 392 return ( tmp ); 393 394 } else 395 if ( mode == PS_SPHERICAL ) { 396 if ( unit == PS_ARCSEC ) { 397 tmpR = ( M_PI * offset->r ) / ( 180.0 * 60.0 * 60.0 ); 398 tmpD = ( M_PI * offset->d ) / ( 180.0 * 60.0 * 60.0 ); 399 } else 400 if ( unit == PS_ARCMIN ) { 401 tmpR = ( M_PI * offset->r ) / ( 180.0 * 60.0 ); 402 tmpD = ( M_PI * offset->d ) / ( 180.0 * 60.0 ); 403 } else 404 if ( unit == PS_DEGREE ) { 405 tmpR = ( M_PI * offset->r ) / ( 180.0 ); 406 tmpD = ( M_PI * offset->d ) / ( 180.0 ); 407 } else 408 if ( unit == PS_RADIAN ) { 409 tmpR = offset->r; 410 tmpD = offset->d; 411 } else { 412 psAbort( __func__, "Unknown offset unit: 0x%x\n", unit ); 413 } 414 415 tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) ); 416 tmp->r = position->r + tmpR; 417 tmp->r = position->d + tmpD; 418 tmp->rErr = 0.0; 419 tmp->dErr = 0.0; 420 421 // XXX: wrap tmp->r and tmp->d to the allowed range (-PI to PI) 422 // and (0 to 2*PI). 423 return ( tmp ); 350 tmp = psDeproject(&lin, &proj); 351 return (tmp); 352 353 } else if (mode == PS_SPHERICAL) { 354 if (unit == PS_ARCSEC) { 355 tmpR = (M_PI * offset->r) / (180.0 * 60.0 * 60.0); 356 tmpD = (M_PI * offset->d) / (180.0 * 60.0 * 60.0); 357 } else if (unit == PS_ARCMIN) { 358 tmpR = (M_PI * offset->r) / (180.0 * 60.0); 359 tmpD = (M_PI * offset->d) / (180.0 * 60.0); 360 } else if (unit == PS_DEGREE) { 361 tmpR = (M_PI * offset->r) / (180.0); 362 tmpD = (M_PI * offset->d) / (180.0); 363 } else if (unit == PS_RADIAN) { 364 tmpR = offset->r; 365 tmpD = offset->d; 366 } else { 367 psAbort(__func__, "Unknown offset unit: 0x%x\n", unit); 424 368 } 425 psAbort( __func__, "Unrecognized offset mode\n" ); 426 return ( NULL ); 427 } 369 370 tmp = (psSphere *) psAlloc(sizeof(psSphere)); 371 tmp->r = position->r + tmpR; 372 tmp->r = position->d + tmpD; 373 tmp->rErr = 0.0; 374 tmp->dErr = 0.0; 375 376 // XXX: wrap tmp->r and tmp->d to the allowed range (-PI to PI) 377 // and (0 to 2*PI). 378 return (tmp); 379 } 380 psAbort(__func__, "Unrecognized offset mode\n"); 381 return (NULL); 382 }
Note:
See TracChangeset
for help on using the changeset viewer.
