Changeset 6030 for trunk/psLib/src/astro/psEarthOrientation.c
- Timestamp:
- Jan 17, 2006, 2:41:29 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psEarthOrientation.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5969 r6030 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-01-1 2 20:40:12$10 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-01-18 00:41:29 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 #define PS_AU 149597890000.0 /* meters */ 40 40 // Modified Julian Day 1/1/2000 00:00:00 41 #define MJD_2000 51544. 041 #define MJD_2000 51544.5 42 42 // Days in Julian century 43 43 #define JULIAN_CENTURY 36525.0 … … 299 299 double a = 0.0; 300 300 301 //mu = apparent * direction; I believe this should be:302 // mu = apparent->r * direction->r + apparent->d * direction->d;303 301 psCube* directionVector = psSphereToCube(direction); 304 302 if (directionVector == NULL) 305 303 printf("directionVector is null\n"); 306 304 psCube* actualVector = psSphereToCube(actual); 307 if ( directionVector == NULL)305 if (actualVector == NULL) 308 306 printf("actualVector is null\n"); 309 307 // mu = acos(directionVector->x*actualVector->x + … … 311 309 directionVector->y*actualVector->y + 312 310 directionVector->z*actualVector->z); 313 314 // rp = apparent - mu * direction;315 // rp->r = actual->r - mu * direction->r;316 // rp->d = actual->d - mu * direction->d;317 311 rp->x = actualVector->x - mu * directionVector->x; 318 312 rp->y = actualVector->y - mu * directionVector->y; 319 313 rp->z = actualVector->z - mu * directionVector->z; 320 314 321 mu_p = mu +speed * ((mu * mu - 1.0) / (1.0 - speed * mu));315 mu_p = mu - speed * ((mu * mu - 1.0) / (1.0 - speed * mu)); 322 316 323 317 //Not sure if this is right. ADD gets a scalar from division of rp (a vector) … … 345 339 //XXX: Must be a sign error somewhere above? Magnitude of change is correct but wrong way... 346 340 //This will fix the problem but is somewhat of a hack. 347 r_p->x = actualVector->x - (r_p->x - actualVector->x);348 r_p->y = actualVector->y - (r_p->y - actualVector->y);349 r_p->z = actualVector->z - (r_p->z - actualVector->z);341 // r_p->x = actualVector->x - (r_p->x - actualVector->x); 342 // r_p->y = actualVector->y - (r_p->y - actualVector->y); 343 // r_p->z = actualVector->z - (r_p->z - actualVector->z); 350 344 351 345 psSphere *r_pSphere = psCubeToSphere(r_p); … … 370 364 PS_ASSERT_PTR_NON_NULL(sun, NULL); 371 365 366 psSphere *temp = psSphereAlloc(); 372 367 // calculating the apparent angle from the actual angle and the sun position 373 368 … … 378 373 // N.B., assuming the psSphereToCube function returns a unit vector. 379 374 // double theta = acos(sunVector->x*actualVector->x + 380 double theta = (sunVector->x*actualVector->x + 381 sunVector->y*actualVector->y + 382 sunVector->z*actualVector->z); 383 printf(" Theta = %lf\n", theta); 375 double dotProd = (sunVector->x*actualVector->x + 376 sunVector->y*actualVector->y + sunVector->z*actualVector->z); 377 double theta, sunMag, actMag; 378 sunMag = sqrt(sunVector->x*sunVector->x + sunVector->y*sunVector->y + 379 sunVector->z*sunVector->z); 380 actMag = sqrt(actualVector->x*actualVector->x + actualVector->y*actualVector->y + 381 actualVector->z*actualVector->z); 382 dotProd = dotProd / (sunMag * actMag); 383 theta = acos(dotProd); 384 385 // theta = acos( cos(sun->d)*cos(actual->d)*cos(sun->r-actual->r) + sin(sun->r)*sin(actual->r) ); 386 387 printf(" Theta = %.13g\n", theta); 384 388 // theta = acos(-theta); 385 389 // printf("\n Theta = %lf\n", theta); 386 390 double r0 = PS_AU * tan(theta); 391 printf(" r0 = %.19e\n", r0); 387 392 double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0); 388 393 … … 390 395 double limit = SEC_TO_RAD(1.75); 391 396 printf(" deflection = %.13g\n", deflection); 392 printf(" limit = %lf\n", limit);397 //printf(" limit = %lf\n", limit); 393 398 if (deflection > limit) { 394 399 // deflection = limit; … … 400 405 } 401 406 402 if (apparent == NULL) { 403 apparent = psSphereAlloc(); 404 } else { 405 apparent->r = 0.0; 406 apparent->d = 0.0; 407 apparent->rErr = 0.0; 408 apparent->dErr = 0.0; 409 } 410 407 /* if (apparent == NULL) { 408 apparent = psSphereAlloc(); 409 } else { 410 apparent->r = 0.0; 411 apparent->d = 0.0; 412 apparent->rErr = 0.0; 413 apparent->dErr = 0.0; 414 } 415 */ 416 if (apparent != NULL) { 417 psFree(apparent); 418 } 411 419 // bend the actual vector away from the sun vector by deflection angle. 412 420 // XXX: Not sure how to do this. Dave thinks the formula should be: … … 414 422 theta = 0.0; 415 423 double phi = 0.0; 416 // deflection = SEC_TO_RAD(deflection); 424 // deflection = SEC_TO_RAD(deflection) * 1e6; 425 // deflection *= M_PI * 1e-2; 417 426 theta = atan(r0/PS_AU) * tan(deflection); 418 printf(" Theta = %.13g\n", theta);419 printf(" deflection = %.13g\n", deflection);420 427 // phi = sqrt( deflection*deflection - theta*theta ); 421 phi = deflection * cos(asin(theta/deflection)) * 3e-2; 428 // phi = deflection * cos(asin(theta/deflection)); 429 430 // phi = sqrt(theta*theta - deflection*deflection); 431 // phi = deflection * cos(asin(theta/deflection)) * 3e-2; 422 432 // phi = cos(asin(theta/deflection)); 423 433 // phi = asin(theta/deflection); 424 apparent->r = theta; 425 apparent->d = phi; 434 435 // apparent->r = theta; 436 // apparent->d = phi; 437 /* 438 actualVector->x += actualVector->x*deflection; 439 actualVector->y += actualVector->y*deflection; 440 actualVector->z += actualVector->z*deflection; 441 apparent = psCubeToSphere(actualVector); 442 */ 443 theta = tan(sun->r - actual->r) * deflection; 444 phi = tan(sun->d - actual->d) * deflection; 445 446 printf(" Theta = %.13g\n", theta); 447 printf(" phi = %.13g\n", phi); 448 449 temp->r = theta; 450 temp->d = phi; 451 apparent = psSphereSetOffset(actual, temp, PS_SPHERICAL, PS_RADIAN); 426 452 427 453 psFree(actualVector); 428 454 psFree(sunVector); 455 psFree(temp); 456 429 457 return apparent; 430 458 } … … 807 835 } 808 836 809 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time) 837 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time, 838 psEarthPole *tidalCorr) 810 839 { 811 840 PS_ASSERT_PTR_NON_NULL(time,NULL); … … 815 844 in = psTimeConvert(in, PS_TIME_UT1); 816 845 } 817 // double T = (double)(in->sec) + (double)(in->nsec / 1e9); 846 if (tidalCorr != NULL && tidalCorr->s != 0.0) { 847 int nsec = in->nsec + (int)(tidalCorr->s * 1e9); 848 if (nsec < 0.0) { 849 in->sec += -1; 850 in->nsec = (int)(1e9) - nsec; 851 } else { 852 in->nsec = nsec; 853 } 854 } 818 855 double T = psTimeToJD(in); 819 856 T += -2451545.0; 820 857 double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T); 821 858 psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0); 822 // psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0);823 859 824 860 psFree(in); … … 919 955 out->x = SEC_TO_RAD(xOut); 920 956 out->y = SEC_TO_RAD(yOut); 957 // psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time); 958 // out->x += polarTideCorr->x; 959 // out->y += polarTideCorr->y; 960 // psFree(polarTideCorr); 961 921 962 // out->s = SEC_TO_RAD(sOut); 922 963 … … 1034 1075 CORX = SEC_TO_RAD(CORX); 1035 1076 CORY = SEC_TO_RAD(CORY); 1036 CORZ = SEC_TO_RAD(CORZ);1077 // CORZ = SEC_TO_RAD(CORZ); 1037 1078 1038 1079 out->x = CORX;
Note:
See TracChangeset
for help on using the changeset viewer.
