Changeset 3451
- Timestamp:
- Mar 18, 2005, 11:36:16 AM (21 years ago)
- Location:
- trunk/psLib/test/astronomy
- Files:
-
- 1 added
- 2 edited
-
Makefile.am (modified) (2 diffs)
-
tst_psCoord.c (modified) (6 diffs)
-
tst_psCoord01.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astronomy/Makefile.am
r3381 r3451 29 29 tst_psAstrometry \ 30 30 tst_psCoord \ 31 tst_psCoord01 \ 31 32 tst_psAstrometry01 32 33 … … 62 63 tst_psAstrometry_SOURCES = tst_psAstrometry.c 63 64 tst_psCoord_SOURCES = tst_psCoord.c 65 tst_psCoord01_SOURCES = tst_psCoord01.c 64 66 tst_psAstrometry01_SOURCES = tst_psAstrometry01.c 65 67 -
trunk/psLib/test/astronomy/tst_psCoord.c
r3432 r3451 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-03-16 03:26:39 $ 10 * 11 * XXX: THe psProject() and psDeproject() functions do not work fully. They 12 * are not tested here. The SphereGet/SetOffset() code that rely on them 13 * is not tested. 8 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-03-18 21:36:16 $ 14 10 * 15 11 * XXX: Test with a bad offfset unit type in the SphereGet/SetOffset() functions. … … 36 32 static psS32 testSphereTransformGalacticToICRS( void ); 37 33 static psS32 testSphereTransformPrecess(void); 38 //static psS32 test20( void );39 //static psS32 test21( void );40 34 static psS32 test40( void ); 41 35 static psS32 test41( void ); 42 //static psS32 test42( void );43 //static psS32 test43( void );44 36 testDescription tests[] = { 45 37 {testSphereTransformAlloc, 819, "psSphereTransformAlloc()", 0, false}, … … 58 50 {testSphereTransformGalacticToICRS, 823, "psSphereTransformGalacticToICRS()", 0, false}, 59 51 {testSphereTransformPrecess, 825, "psSphereTransformPrecess()", 0, false}, 60 // {test20, 0000, "psProject()", 0, false},61 // {test21, 0000, "psDeProject()", 0, false},62 52 {test40, 0000, "psSphereGetOffset()", 0, false}, 63 53 {test41, 0000, "psSphereSetOffset()", 0, false}, 64 // {test42, 0000, "psProject(), psDeproject", 0, false},65 // {test43, 0000, "psProject(), psDeproject", 0, false},66 54 {NULL} 67 55 }; … … 506 494 return 3; 507 495 } 508 // printf("psSphereTransformApply (%f, %f) -> (%f, %f)\n", out.r, out.d, in.r, in.d);509 496 } 510 497 } … … 1392 1379 } 1393 1380 1394 psS32 test20( void )1395 {1396 psS32 testStatus = 0;1397 psSphere in;1398 double expectX;1399 double expectY;1400 psPlane *out;1401 psProjection myProjection;1402 myProjection.R = DEG_TO_RAD(20.0);1403 myProjection.D = DEG_TO_RAD(10.0);1404 myProjection.Xs = 1.0;1405 myProjection.Ys = 1.0;1406 1407 for (float r=0.0;r<180.0;r+=DEG_INC) {1408 for (float d=0.0;d<90.0;d+=DEG_INC) {1409 in.r = DEG_TO_RAD(r);1410 in.d = DEG_TO_RAD(d);1411 in.rErr = 0.0;1412 in.dErr = 0.0;1413 1414 /******************************************************************1415 Tangent Plane Projection1416 *****************************************************************/1417 myProjection.type = PS_PROJ_TAN;1418 out = psProject(&in, &myProjection);1419 expectX = cos(in.r) * sin(in.d) / sin(in.r);1420 expectY = -cos(in.r) * cos(in.d) / sin(in.r);1421 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 1);1422 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 2);1423 psFree(out);1424 1425 /******************************************************************1426 PS_PROJ_SIN Projection1427 *****************************************************************/1428 myProjection.type = PS_PROJ_SIN;1429 out = psProject(&in, &myProjection);1430 expectX = cos(in.d) * sin(in.d);1431 expectY = -cos(in.d) * cos(in.d);1432 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 3);1433 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 4);1434 psFree(out);1435 1436 /******************************************************************1437 PS_PROJ_CAR Projection1438 *****************************************************************/1439 myProjection.type = PS_PROJ_CAR;1440 out = psProject(&in, &myProjection);1441 1442 expectX = in.d;1443 expectY = in.r;1444 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 5);1445 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 6);1446 psFree(out);1447 1448 /******************************************************************1449 PS_PROJ_MER Projection1450 *****************************************************************/1451 myProjection.type = PS_PROJ_MER;1452 out = psProject(&in, &myProjection);1453 1454 expectX = in.d;1455 expectY = log(tan(DEG_TO_RAD(45.0) + (0.5 * in.r)));1456 1457 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 7);1458 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 8);1459 psFree(out);1460 1461 /******************************************************************1462 PS_PROJ_AIT Projection1463 *****************************************************************/1464 myProjection.type = PS_PROJ_AIT;1465 out = psProject(&in, &myProjection);1466 1467 1468 psF64 tmpF64 = PS_SQRT_F32(0.5 * (1.0 + (cos(in.r) * cos(0.5 * in.d))));1469 tmpF64 = 1.0 / tmpF64;1470 expectX = 2.0 * tmpF64 * cos(in.r) * sin(0.5 * in.d);1471 expectY = sin(in.r) * tmpF64;1472 1473 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 20);1474 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 21);1475 psFree(out);1476 1477 1478 }1479 }1480 1481 printf("-------------------------------------------------------------------\n");1482 printf("Calling psProject() with NULL input coords. Should generate error, return NULL.\n");1483 out = psProject(NULL, &myProjection);1484 if (out != NULL) {1485 printf("TEST ERROR: psSphereTransformEclipticToICRS() did not return NULL.\n");1486 testStatus = false;1487 out = NULL;1488 }1489 1490 printf("-------------------------------------------------------------------\n");1491 printf("Calling psProject() with NULL psProjection. Should generate error, return NULL.\n");1492 out = psProject(&in, NULL);1493 if (out != NULL) {1494 printf("TEST ERROR: psProject() did not return NULL.\n");1495 testStatus = false;1496 out = NULL;1497 }1498 1499 printf("-------------------------------------------------------------------\n");1500 1501 return(testStatus);1502 }1503 1504 #define SPACE_INC 10.01505 psS32 test21( void )1506 {1507 psS32 testStatus = 0;1508 psPlane in;1509 double R;1510 double expectD;1511 double expectR;1512 psSphere *out;1513 psProjection myProjection;1514 myProjection.R = DEG_TO_RAD(20.0);1515 myProjection.D = DEG_TO_RAD(10.0);1516 myProjection.Xs = 1.0;1517 myProjection.Ys = 1.0;1518 1519 in.xErr = 0.0;1520 in.yErr = 0.0;1521 for (in.x=0.0; in.x<100.0; in.x+=SPACE_INC) {1522 for (in.y=0.0;in.y<100.0;in.y+=SPACE_INC) {1523 1524 /******************************************************************1525 Tangent Plane Projection1526 *****************************************************************/1527 myProjection.type = PS_PROJ_TAN;1528 out = psDeproject(&in, &myProjection);1529 1530 R = PS_SQRT_F32((in.x * in.x) + (in.y * in.y));1531 expectD = atan(1.0 / R);1532 expectR = atan2(-in.y, in.x);1533 1534 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 1);1535 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 2);1536 psFree(out);1537 1538 /******************************************************************1539 PS_PROJ_SIN Projection1540 *****************************************************************/1541 myProjection.type = PS_PROJ_SIN;1542 out = psDeproject(&in, &myProjection);1543 1544 R = sqrt((in.x * in.x) + (in.y * in.y));1545 expectD = p_psArg(-in.y, in.x);1546 expectR = acos((R * M_PI) / 180.0);1547 1548 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);1549 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);1550 psFree(out);1551 1552 /******************************************************************1553 PS_PROJ_CAR Projection1554 *****************************************************************/1555 myProjection.type = PS_PROJ_CAR;1556 out = psDeproject(&in, &myProjection);1557 1558 expectD = in.x;1559 expectR = in.y;1560 1561 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);1562 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);1563 psFree(out);1564 1565 /******************************************************************1566 PS_PROJ_MER Projection1567 *****************************************************************/1568 myProjection.type = PS_PROJ_MER;1569 out = psDeproject(&in, &myProjection);1570 1571 expectD = in.x;1572 expectR = (2.0 * atan(exp((in.y * M_PI / 180.0)))) - 180.0;1573 1574 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);1575 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);1576 psFree(out);1577 1578 1579 /******************************************************************1580 PS_PROJ_AIT Projection1581 *****************************************************************/1582 myProjection.type = PS_PROJ_AIT;1583 out = psDeproject(&in, &myProjection);1584 1585 float chu1 = (in.x * M_PI) / 720.0;1586 chu1 *= chu1;1587 float chu2 = (in.y * M_PI) / 360.0;1588 chu2 *= chu2;1589 float chu = sqrt(1.0 - chu1 - chu2);1590 expectD = 2.0 * p_psArg((2.0 * chu * chu) - 1.0, (in.x * chu * M_PI) / 360.0);1591 expectR = asin((in.y * chu * M_PI) / 180.0);1592 1593 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);1594 PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);1595 psFree(out);1596 }1597 }1598 1599 printf("-------------------------------------------------------------------\n");1600 printf("Calling psDeproject() with NULL input coords. Should generate error, return NULL.\n");1601 out = psDeproject(NULL, &myProjection);1602 if (out != NULL) {1603 printf("TEST ERROR: psDeproject() did not return NULL.\n");1604 testStatus = false;1605 out = NULL;1606 }1607 1608 printf("-------------------------------------------------------------------\n");1609 printf("Calling psDeproject() with NULL psProjection. Should generate error, return NULL.\n");1610 out = psDeproject(&in, NULL);1611 if (out != NULL) {1612 printf("TEST ERROR: psDeproject() did not return NULL.\n");1613 testStatus = false;1614 out = NULL;1615 }1616 1617 printf("-------------------------------------------------------------------\n");1618 1619 return(testStatus);1620 }1621 1381 1622 1382 psS32 test40( void ) … … 1882 1642 } 1883 1643 1884 #define NUM_DEGREES 51885 /******************************************************************************1886 test42(): This test attempts to verify the psProject() and psDeproject()1887 functions. We create an arbitrary psProjection. We then project several1888 spherical coordinates onto the plane and then immediately deproject them; we1889 ensure that the resulting spherical coordinates are identical to the start1890 coordinates.1891 1892 Currently, this test works only for angles near the first quadrant.1893 *****************************************************************************/1894 psS32 test42( void )1895 {1896 psS32 testStatus = 0;1897 psSphere projCenter;1898 psSphere startCoords;1899 psSphere *endCoords;1900 psPlane *planeCoords;1901 1902 #define PROG_CENTER_R_DEG 15.01903 #define PROG_CENTER_D_DEG 20.01904 1905 projCenter.r = DEG_TO_RAD(PROG_CENTER_R_DEG);1906 projCenter.d = DEG_TO_RAD(PROG_CENTER_D_DEG);1907 // Create the psProjection plane:1908 psProjection myProj;1909 myProj.R = projCenter.r;1910 myProj.D = projCenter.d;1911 myProj.Xs = 1.0;1912 myProj.Ys = 1.0;1913 myProj.type = PS_PROJ_TAN;1914 1915 #define RADIUS_DEG 30.01916 #define NUM_ANGLES 301917 #define MY_DEG_INC ((2.0 * RADIUS_DEG) / NUM_ANGLES)1918 1919 for (float r= (PROG_CENTER_R_DEG - RADIUS_DEG);1920 r<=(PROG_CENTER_R_DEG + RADIUS_DEG);1921 r+=MY_DEG_INC) {1922 printf("------------------------ r is %.1f ------------------------\n", r);1923 for (float d= (PROG_CENTER_D_DEG - RADIUS_DEG);1924 d<=(PROG_CENTER_D_DEG + RADIUS_DEG);1925 d+=MY_DEG_INC) {1926 startCoords.r = DEG_TO_RAD(r);1927 startCoords.d = DEG_TO_RAD(d);1928 printf("----- startCoords (R, D) is (%f, %f) is deg (%.1f, %.1f) -----\n", startCoords.r, startCoords.d, r, d);1929 1930 planeCoords = psProject(&startCoords, &myProj);1931 endCoords = psDeproject(planeCoords, &myProj);1932 1933 if (testNonEqualF32(endCoords->r, startCoords.r) ||1934 testNonEqualF32(endCoords->d, startCoords.d)) {1935 printf("ERROR: \n");1936 printf(" startCoords (R, D) is (%f, %f)\n", startCoords.r, startCoords.d);1937 // printf(" plane Coords is (%f, %f)\n", planeCoords->x, planeCoords->y);1938 printf(" endCoords (R, D) is (%f, %f)\n", endCoords->r, endCoords->d);1939 }1940 psFree(planeCoords);1941 psFree(endCoords);1942 }1943 }1944 return(testStatus);1945 }1946 1947 // This code will ...1948
Note:
See TracChangeset
for help on using the changeset viewer.
