Changeset 6184 for trunk/psLib/src/astro/psEarthOrientation.c
- Timestamp:
- Jan 23, 2006, 10:04:31 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psEarthOrientation.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r6039 r6184 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-01- 18 23:49:06$10 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-01-23 20:04:31 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 1462 1462 } 1463 1463 1464 /****************************************************************************** 1465 psSpherePrecess(coords, fromTime, toTime): 1466 1467 XXX: Use static memory for tmpST. 1468 *****************************************************************************/ 1469 psSphere *psSpherePrecess(psSphere *coords, 1470 const psTime *fromTime, 1471 const psTime *toTime) 1464 psSphereRot *psSpherePrecess(const psTime *fromTime, 1465 const psTime *toTime, 1466 psPrecessMethod mode) 1472 1467 { 1473 1468 // Check input for NULL pointers 1474 PS_ASSERT_PTR_NON_NULL(coords, NULL); 1475 PS_ASSERT_PTR_NON_NULL(fromTime, NULL); 1476 PS_ASSERT_PTR_NON_NULL(toTime, NULL); 1477 1469 if (fromTime == NULL && toTime == NULL) { 1470 psError(PS_ERR_BAD_PARAMETER_NULL, true, 1471 "Invalid time inputs. fromTime & toTime cannot both be NULL.\n"); 1472 return NULL; 1473 } 1474 PS_ASSERT_INT_WITHIN_RANGE(mode, PS_PRECESS_ROUGH, PS_PRECESS_IAU2000A, NULL); 1475 psF64 fromMJD, toMJD; 1478 1476 // Calculate Julian centuries 1479 psF64 fromMJD = psTimeToMJD(fromTime); 1480 psF64 toMJD = psTimeToMJD(toTime); 1481 psF64 T = (toMJD - fromMJD) / JULIAN_CENTURY; 1482 1483 // Calculate conversion constants 1484 // psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 1485 psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1486 (DEG_TO_RAD(0.0000839) * T * T) + 1487 (DEG_TO_RAD(0.000005) * T * T * T)); 1488 1489 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 1490 (DEG_TO_RAD(0.0001185) * T * T) - 1491 (DEG_TO_RAD(0.0000116) * T * T * T); 1492 1493 // psF64 phiP = DEG_TO_RAD(90.0) + ((DEG_TO_RAD(0.6406161) * T) + 1494 psF64 phiP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1495 (DEG_TO_RAD(0.0003041) * T * T) + 1496 (DEG_TO_RAD(0.0000051) * T * T * T)); 1497 1498 // Create transform with proper constants 1499 psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP); 1500 1477 //If either input time is NULL, assume it to be J2000 -> from SDRS as of rev 18 1478 if (fromTime == NULL) { 1479 fromMJD = MJD_2000; 1480 } else { 1481 fromMJD = psTimeToMJD(fromTime); 1482 } 1483 if (toTime == NULL) { 1484 toMJD = MJD_2000; 1485 } else { 1486 toMJD = psTimeToMJD(toTime); 1487 } 1488 psTime *from = NULL; 1489 psTime *to = NULL; 1490 1491 if (mode == PS_PRECESS_ROUGH) { 1492 //For PS_PRECESS_ROUGH, no time/earthpole corrections are used. This is the 1493 //lowest level of detail mode. 1494 psF64 T = (toMJD - fromMJD) / JULIAN_CENTURY; 1495 1496 // Calculate conversion constants 1497 // psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 1498 psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1499 (DEG_TO_RAD(0.0000839) * T * T) + 1500 (DEG_TO_RAD(0.000005) * T * T * T)); 1501 1502 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 1503 (DEG_TO_RAD(0.0001185) * T * T) - 1504 (DEG_TO_RAD(0.0000116) * T * T * T); 1505 1506 // psF64 phiP = DEG_TO_RAD(90.0) + ((DEG_TO_RAD(0.6406161) * T) + 1507 psF64 phiP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1508 (DEG_TO_RAD(0.0003041) * T * T) + 1509 (DEG_TO_RAD(0.0000051) * T * T * T)); 1510 1511 // Create transform with proper constants 1512 psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP); 1513 return tmpST; 1514 } else if (mode == PS_PRECESS_IAU2000A) { 1515 //For IAU2000A mode, run psEOC_PrecessionModel and then psSphereRot_CEOtoGCRS for 1516 //each time. Then difference the resulting rotations by adding the inverse 1517 //rotation corresponding to fromTime to the toTime rotation. 1518 1519 //Since the time inputs are allowed to be NULL, either convert the MJD time 1520 //or copy to non-NULL time 1521 if (fromTime == NULL) { 1522 from = psTimeFromMJD(fromMJD); 1523 } else { 1524 from = p_psTimeCopy(fromTime); 1525 } 1526 if (toTime == NULL) { 1527 to = psTimeFromMJD(toMJD); 1528 } else { 1529 to = p_psTimeCopy(toTime); 1530 } 1531 1532 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1533 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1534 psEarthPole *toEP = psEOC_PrecessionModel(to); 1535 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1536 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1537 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1538 psFree(from); 1539 psFree(to); 1540 psFree(fromEP); 1541 psFree(fromRot); 1542 psFree(toEP); 1543 psFree(toRot); 1544 psFree(fromConj); 1545 return out; 1546 } else if (mode == PS_PRECESS_COMPLETE_A) { 1547 //For PS_PRECESS_COMPLETE_A the same procedure as IAU2000A is used but with 1548 //additional earthpole corrections from psEOC_PrecessionCorr. The corrections 1549 //for COMPLETE_A come from the IERS Bulletin A. 1550 1551 //Since the time inputs are allowed to be NULL, either convert the MJD time 1552 //or copy to non-NULL time 1553 if (fromTime == NULL) { 1554 from = psTimeFromMJD(fromMJD); 1555 } else { 1556 from = p_psTimeCopy(fromTime); 1557 } 1558 if (toTime == NULL) { 1559 to = psTimeFromMJD(toMJD); 1560 } else { 1561 to = p_psTimeCopy(toTime); 1562 } 1563 1564 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1565 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_A); 1566 fromEP->x += fromCorr->x; 1567 fromEP->y += fromCorr->y; 1568 fromEP->s += fromCorr->s; 1569 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1570 psEarthPole *toEP = psEOC_PrecessionModel(to); 1571 psEarthPole *toCorr = psEOC_PrecessionCorr(to, PS_IERS_A); 1572 toEP->x += toCorr->x; 1573 toEP->y += toCorr->y; 1574 toEP->s += toCorr->s; 1575 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1576 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1577 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1578 psFree(from); 1579 psFree(to); 1580 psFree(fromEP); 1581 psFree(fromCorr); 1582 psFree(fromRot); 1583 psFree(toEP); 1584 psFree(toCorr); 1585 psFree(toRot); 1586 psFree(fromConj); 1587 return out; 1588 } else { //mode == PS_PRECESS_COMPLETE_B 1589 //For PS_PRECESS_COMPLETE_B the same procedure as IAU2000A is used but with 1590 //additional earthpole corrections from psEOC_PrecessionCorr. The corrections 1591 //for COMPLETE_B come from the IERS Bulletin B. 1592 1593 //Since the time inputs are allowed to be NULL, either convert the MJD time 1594 //or copy to non-NULL time 1595 if (fromTime == NULL) { 1596 from = psTimeFromMJD(fromMJD); 1597 } else { 1598 from = p_psTimeCopy(fromTime); 1599 } 1600 if (toTime == NULL) { 1601 to = psTimeFromMJD(toMJD); 1602 } else { 1603 to = p_psTimeCopy(toTime); 1604 } 1605 1606 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1607 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_B); 1608 fromEP->x += fromCorr->x; 1609 fromEP->y += fromCorr->y; 1610 fromEP->s += fromCorr->s; 1611 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1612 psEarthPole *toEP = psEOC_PrecessionModel(to); 1613 psEarthPole *toCorr = psEOC_PrecessionCorr(to, PS_IERS_B); 1614 toEP->x += toCorr->x; 1615 toEP->y += toCorr->y; 1616 toEP->s += toCorr->s; 1617 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1618 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1619 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1620 psFree(from); 1621 psFree(to); 1622 psFree(fromEP); 1623 psFree(fromCorr); 1624 psFree(fromRot); 1625 psFree(toEP); 1626 psFree(toCorr); 1627 psFree(toRot); 1628 psFree(fromConj); 1629 return out; 1630 } 1501 1631 // Apply transform to coordinates 1502 psSphere *out = psSphereRotApply(NULL, tmpST, coords); 1503 if (out->r < -0.0001) { 1504 out->r += 2.0 * M_PI; 1505 } 1506 1507 psFree(tmpST); 1508 1509 return(out); 1632 // psSphere *out = psSphereRotApply(NULL, tmpST, coords); 1633 // if (out->r < -0.0001) { 1634 // out->r += 2.0 * M_PI; 1635 // } 1510 1636 }
Note:
See TracChangeset
for help on using the changeset viewer.
