Changeset 5090 for trunk/psLib/src/astro
- Timestamp:
- Sep 21, 2005, 4:47:16 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psCoord.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r4991 r5090 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.8 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-09- 11 22:18:40$12 * @version $Revision: 1.87 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-22 02:47:16 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 90 90 91 91 A = transform->x->coeff[0][0]; 92 if (transform->x-> nX >= 2) {92 if (transform->x->COOL_2D_nX >= 1) { 93 93 B = transform->x->coeff[1][0]; 94 94 } 95 if (transform->x-> nY >= 2) {95 if (transform->x->COOL_2D_nY >= 1) { 96 96 C = transform->x->coeff[0][1]; 97 97 } 98 98 D = transform->y->coeff[0][0]; 99 if (transform->y-> nX >= 2) {99 if (transform->y->COOL_2D_nX >= 1) { 100 100 E = transform->y->coeff[1][0]; 101 101 } 102 if (transform->y-> nY >= 2) {102 if (transform->y->COOL_2D_nY >= 1) { 103 103 F = transform->y->coeff[0][1]; 104 104 } … … 154 154 PS_ASSERT_PTR_NON_NULL(transform->y, 0); 155 155 156 for (psS32 i=0;i<( transform->x->nX);i++) {157 for (psS32 j=0;j<( transform->x->nY);j++) {156 for (psS32 i=0;i<(1 + transform->x->COOL_2D_nX);i++) { 157 for (psS32 j=0;j<(1 + transform->x->COOL_2D_nY);j++) { 158 158 if (transform->x->coeff[i][j] != 0.0) { 159 159 if (!(((i == 0) && (j == 0)) || … … 166 166 } 167 167 168 for (psS32 i=0;i<( transform->y->nX);i++) {169 for (psS32 j=0;j<( transform->y->nY);j++) {168 for (psS32 i=0;i<(1 + transform->y->COOL_2D_nX);i++) { 169 for (psS32 j=0;j<(1 + transform->y->COOL_2D_nY);j++) { 170 170 if (transform->y->coeff[i][j] != 0.0) { 171 171 if (!(((i == 0) && (j == 0)) || … … 208 208 } 209 209 210 // XXX: Verify the order/nterms poly changes 210 211 psPlaneTransform* psPlaneTransformAlloc(int n1, int n2) 211 212 { … … 214 215 215 216 psPlaneTransform *pt = psAlloc(sizeof(psPlaneTransform)); 216 pt->x = psPolynomial2DAlloc(n1 , n2, PS_POLYNOMIAL_ORD);217 pt->y = psPolynomial2DAlloc(n1 , n2, PS_POLYNOMIAL_ORD);217 pt->x = psPolynomial2DAlloc(n1-1, n2-1, PS_POLYNOMIAL_ORD); 218 pt->y = psPolynomial2DAlloc(n1-1, n2-1, PS_POLYNOMIAL_ORD); 218 219 219 220 psMemSetDeallocator(pt, (psFreeFunc) planeTransformFree); … … 276 277 } 277 278 279 // XXX: Verify the order/nterms poly changes 278 280 psPlaneDistort* psPlaneDistortAlloc(int n1, int n2, int n3, int n4) 279 281 { … … 284 286 285 287 psPlaneDistort *pt = psAlloc(sizeof(psPlaneDistort)); 286 pt->x = psPolynomial4DAlloc(n1 , n2, n3, n4, PS_POLYNOMIAL_ORD);287 pt->y = psPolynomial4DAlloc(n1 , n2, n3, n4, PS_POLYNOMIAL_ORD);288 pt->x = psPolynomial4DAlloc(n1-1, n2-1, n3-1, n4-1, PS_POLYNOMIAL_ORD); 289 pt->y = psPolynomial4DAlloc(n1-1, n2-1, n3-1, n4-1, PS_POLYNOMIAL_ORD); 288 290 289 291 psMemSetDeallocator(pt, (psFreeFunc) planeDistortFree); … … 499 501 psPolynomial2D *trans2) 500 502 { 501 //TRACE: printf("multiplyDPoly2D(%d %d: %d %d)\n", trans1->nX, trans1->nY, trans2->nX, trans2->nY); 502 psS32 orderX = (trans1->nX + trans2->nX) - 1; 503 psS32 orderY = (trans1->nY + trans2->nY) - 1; 504 505 psPolynomial2D *out = psPolynomial2DAlloc(orderX, orderY, PS_POLYNOMIAL_ORD); 503 //TRACE: printf("multiplyDPoly2D(%d %d: %d %d)\n", trans1->COOL_2D_nX, trans1->COOL_2D_nY, trans2->COOL_2D_nX, trans2->COOL_2D_nY); 504 // XXX: OLD: psS32 orderX = (trans1->nX + trans2->nX) - 1; 505 // XXX: Verify this (the poly order change) 506 psS32 orderX = trans1->COOL_2D_nX + trans2->COOL_2D_nX + 1; 507 psS32 orderY = trans1->COOL_2D_nY + trans2->COOL_2D_nY + 1; 508 509 // XXX: Verify this (the poly order change) 510 psPolynomial2D *out = psPolynomial2DAlloc(orderX-1, orderY-1, PS_POLYNOMIAL_ORD); 506 511 //TRACE: printf("Creating poly (%d, %d)\n", orderX, orderY); 507 for (psS32 i = 0 ; i < out->nX; i++) {508 for (psS32 j = 0 ; j < out->nY; j++) {512 for (psS32 i = 0 ; i < (1 + out->COOL_2D_nX); i++) { 513 for (psS32 j = 0 ; j < (1 + out->COOL_2D_nY); j++) { 509 514 out->coeff[i][j] = 0.0; 510 515 out->mask[i][j] = 0; … … 512 517 } 513 518 514 for (psS32 t1x = 0 ; t1x < trans1->nX; t1x++) {515 for (psS32 t1y = 0 ; t1y < trans1->nY; t1y++) {519 for (psS32 t1x = 0 ; t1x < (1 + trans1->COOL_2D_nX) ; t1x++) { 520 for (psS32 t1y = 0 ; t1y < (1 + trans1->COOL_2D_nY) ; t1y++) { 516 521 if (0.0 != trans1->coeff[t1x][t1y]) { 517 for (psS32 t2x = 0 ; t2x < trans2->nX; t2x++) {518 for (psS32 t2y = 0 ; t2y < trans2->nY; t2y++) {522 for (psS32 t2x = 0 ; t2x < (1 + trans2->COOL_2D_nX) ; t2x++) { 523 for (psS32 t2y = 0 ; t2y < (1 + trans2->COOL_2D_nY) ; t2y++) { 519 524 /* Possible debug-only macro which checks these coords? 520 525 if ((t1x+t2x) >= orderX) … … 547 552 PS_ASSERT_PTR_NON_NULL(trans1, NULL); 548 553 PS_ASSERT_PTR_NON_NULL(trans2, NULL); 549 //TRACE: printf("psPlaneTransformCombine(%d, %d, %d, %d: %d, %d, %d, %d)\n", trans1->x-> nX, trans1->x->nY, trans1->y->nX, trans1->y->nY, trans2->x->nX, trans2->x->nY, trans2->y->nX, trans2->y->nY);554 //TRACE: printf("psPlaneTransformCombine(%d, %d, %d, %d: %d, %d, %d, %d)\n", trans1->x->COOL_2D_nX, trans1->x->COOL_2D_nY, trans1->y->COOL_2D_nX, trans1->y->COOL_2D_nY, trans2->x->COOL_2D_nX, trans2->x->COOL_2D_nY, trans2->y->COOL_2D_nX, trans2->y->COOL_2D_nY); 550 555 // 551 556 // Determine the size of the new psPlaneTransform. … … 553 558 // PS_MAX( Number of x terms in T2->x * number of x terms in T1->x, 554 559 // Number of y terms in T2->x * number of x terms in T1->y, 555 psS32 orderXnX = PS_MAX(( trans2->x->nX * trans1->x->nX),556 ( trans2->x->nY * trans1->y->nX));557 psS32 orderXnY = PS_MAX(( trans2->x->nX * trans1->x->nY),558 ( trans2->x->nY * trans1->y->nY));559 560 psS32 orderYnX = PS_MAX(( trans2->y->nX * trans1->x->nX),561 ( trans2->y->nY * trans1->y->nX));562 psS32 orderYnY = PS_MAX(( trans2->y->nX * trans1->x->nY),563 ( trans2->y->nY * trans1->y->nY));560 psS32 orderXnX = PS_MAX(((1 + trans2->x->COOL_2D_nX) * (1 + trans1->x->COOL_2D_nX)), 561 ((1 + trans2->x->COOL_2D_nY) * (1 + trans1->y->COOL_2D_nX))); 562 psS32 orderXnY = PS_MAX(((1 + trans2->x->COOL_2D_nX) * (1 + trans1->x->COOL_2D_nY)), 563 ((1 + trans2->x->COOL_2D_nY) * (1 + trans1->y->COOL_2D_nY))); 564 565 psS32 orderYnX = PS_MAX(((1 + trans2->y->COOL_2D_nX) * (1 + trans1->x->COOL_2D_nX)), 566 ((1 + trans2->y->COOL_2D_nY) * (1 + trans1->y->COOL_2D_nX))); 567 psS32 orderYnY = PS_MAX(((1 + trans2->y->COOL_2D_nX) * (1 + trans1->x->COOL_2D_nY)), 568 ((1 + trans2->y->COOL_2D_nY) * (1 + trans1->y->COOL_2D_nY))); 564 569 psS32 orderX = PS_MAX(orderXnX, orderYnX); 565 570 psS32 orderY = PS_MAX(orderXnY, orderYnY); … … 568 573 // Allocate the new psPlaneTransform, if necessary. 569 574 // 575 // XXX: rename, or verify, or recode, after the poly norder/nterm change. 570 576 psPlaneTransform *myPT = NULL; 571 577 if (out == NULL) { 572 578 myPT = psPlaneTransformAlloc(orderX, orderY); 573 579 } else { 574 if (( out->x->nX == orderX) && (out->x->nY== orderY) &&575 ( out->y->nX == orderX) && (out->y->nY== orderY)) {580 if (((1 + out->x->COOL_2D_nX) == orderX) && ((1 + out->x->COOL_2D_nY) == orderY) && 581 ((1 + out->y->COOL_2D_nX) == orderX) && ((1 + out->y->COOL_2D_nY) == orderY)) { 576 582 myPT = out; 577 583 } else { … … 603 609 // 604 610 605 for (psS32 t2x = 0 ; t2x < trans2->x->nX ; t2x++) { 606 for (psS32 t2y = 0 ; t2y < trans2->x->nY ; t2y++) { 607 psPolynomial2D *currPoly = psPolynomial2DAlloc(1, 1, PS_POLYNOMIAL_ORD); 611 for (psS32 t2x = 0 ; t2x < (1 + trans2->x->COOL_2D_nX) ; t2x++) { 612 for (psS32 t2y = 0 ; t2y < (1 + trans2->x->COOL_2D_nX) ; t2y++) { 613 // XXX: Verify this (poly order/nterm change) 614 psPolynomial2D *currPoly = psPolynomial2DAlloc(1-1, 1-1, PS_POLYNOMIAL_ORD); 608 615 609 616 currPoly->coeff[0][0] = 1.0; … … 627 634 628 635 // Set the appropriate coeffs in myPT->x 629 for (psS32 i = 0 ; i < currPoly->nX; i++) {630 for (psS32 j = 0 ; j < currPoly->nY; j++) {636 for (psS32 i = 0 ; i < (1 + currPoly->COOL_2D_nX) ; i++) { 637 for (psS32 j = 0 ; j < (1 + currPoly->COOL_2D_nY) ; j++) { 631 638 myPT->x->coeff[i][j]+= currPoly->coeff[i][j] * trans2->x->coeff[t2x][t2y]; 632 639 } … … 638 645 639 646 640 for (psS32 t2x = 0 ; t2x < trans2->y->nX ; t2x++) { 641 for (psS32 t2y = 0 ; t2y < trans2->y->nY ; t2y++) { 642 psPolynomial2D *currPoly = psPolynomial2DAlloc(1, 1, PS_POLYNOMIAL_ORD); 647 for (psS32 t2x = 0 ; t2x < (1 + trans2->y->COOL_2D_nX) ; t2x++) { 648 for (psS32 t2y = 0 ; t2y < (1 + trans2->y->COOL_2D_nY) ; t2y++) { 649 // XXX: Verify this (poly order/nterm change) 650 psPolynomial2D *currPoly = psPolynomial2DAlloc(1-1, 1-1, PS_POLYNOMIAL_ORD); 643 651 currPoly->coeff[0][0] = 1.0; 644 652 currPoly->mask[0][0] = 0; … … 662 670 663 671 // Set the appropriate coeffs in myPT->x 664 for (psS32 i = 0 ; i < currPoly->nX; i++) {665 for (psS32 j = 0 ; j < currPoly->nY; j++) {672 for (psS32 i = 0 ; i < (1 + currPoly->COOL_2D_nX) ; i++) { 673 for (psS32 j = 0 ; j < (1 + currPoly->COOL_2D_nY) ; j++) { 666 674 myPT->y->coeff[i][j]+= currPoly->coeff[i][j] * trans2->y->coeff[t2x][t2y]; 667 675 } … … 694 702 695 703 psS32 numCoords = PS_MIN(source->n, dest->n); 696 psS32 order = PS_MAX(trans->x->nX, trans->x->nY); 697 order = PS_MAX(order, trans->y->nX); 698 order = PS_MAX(order, trans->y->nY); 704 psS32 order = PS_MAX(trans->x->COOL_2D_nX, trans->x->COOL_2D_nY); 705 order = PS_MAX(order, trans->y->COOL_2D_nX); 706 order = PS_MAX(order, trans->y->COOL_2D_nY); 707 // XXX: Verify, or recode, after the poly norder/nterm change. 708 order++; 699 709 700 710 // 701 711 // Create fake polynomial to use in evaluation 702 712 // 703 psPolynomial2D *fakePoly = psPolynomial2DAlloc(order, order, PS_POLYNOMIAL_ORD); 713 // XXX: Verify this (poly order/nterm change) 714 psPolynomial2D *fakePoly = psPolynomial2DAlloc(order-1, order-1, PS_POLYNOMIAL_ORD); 704 715 for (int i = 0; i < order; i++) { 705 716 for (int j = 0; j < order; j++) { … … 811 822 812 823 // Ensure that the input transformation is symmetrical. 813 if ((in->x-> nX != in->x->nY) ||814 (in->y-> nX != in->y->nY) ||815 (in->x-> nX != in->y->nX)) {824 if ((in->x->COOL_2D_nX != in->x->COOL_2D_nY) || 825 (in->y->COOL_2D_nX != in->y->COOL_2D_nY) || 826 (in->x->COOL_2D_nX != in->y->COOL_2D_nX)) { 816 827 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Input transformation must have same nX==nY."); 817 828 } 818 psS32 order = in->x->nX; 829 // XXX: recode or verify after poly changes 830 psS32 order = 1 + in->x->COOL_2D_nX; 819 831 820 832 psPlaneTransform *myPT = NULL; … … 826 838 // 827 839 if (out == NULL) { 840 // XXX: Verify this (poly order/nterm change) 828 841 myPT = psPlaneTransformAlloc(order, order); 829 842 } else { 830 if ((out->x->nX == order) && (out->x->nY == order) && 831 (out->y->nX == order) && (out->y->nY == order)) { 843 // XXX: recode or verify after poly changes 844 if (((1 + out->x->COOL_2D_nX) == order) && ((1 + out->x->COOL_2D_nY) == order) && 845 ((1 + out->y->COOL_2D_nX) == order) && ((1 + out->y->COOL_2D_nX) == order)) { 832 846 myPT = out; 833 847 } else { … … 840 854 // Copy the input transform to myPT. 841 855 // 842 for (psS32 i = 0 ; i < in->x->nX; i++) {843 for (psS32 j = 0 ; j < in->x->nY; j++) {856 for (psS32 i = 0 ; i < (1 + in->x->COOL_2D_nX) ; i++) { 857 for (psS32 j = 0 ; j < (1 + in->x->COOL_2D_nY) ; j++) { 844 858 myPT->x->coeff[i][j] = in->x->coeff[i][j]; 845 859 } 846 860 } 847 for (psS32 i = 0 ; i < in->y->nX; i++) {848 for (psS32 j = 0 ; j < in->y->nY; j++) {861 for (psS32 i = 0 ; i < (1 + in->y->COOL_2D_nX) ; i++) { 862 for (psS32 j = 0 ; j < (1 + in->y->COOL_2D_nY) ; j++) { 849 863 myPT->y->coeff[i][j] = in->y->coeff[i][j]; 850 864 } … … 926 940 927 941 // This loop starts at loop_x=1 since the derivative of the loop_x=0 terms are all 0.0 928 for (psS32 loop_x = 1; loop_x < xPoly->nX; loop_x++) {942 for (psS32 loop_x = 1; loop_x < (1 + xPoly->COOL_2D_nX); loop_x++) { 929 943 ySum = 1.0; 930 for (psS32 loop_y = 0; loop_y < xPoly->nY; loop_y++) {944 for (psS32 loop_y = 0; loop_y < (1 + xPoly->COOL_2D_nY); loop_y++) { 931 945 // 932 946 // For each iteration of the loop, we multiple the (x, y) coefficient … … 946 960 947 961 // This loop starts at loop_y=1 since the derivative of the loop_y=0 terms are all 0.0 948 for (psS32 loop_x = 0; loop_x < yPoly->nX; loop_x++) {962 for (psS32 loop_x = 0; loop_x < (1 + yPoly->COOL_2D_nX); loop_x++) { 949 963 ySum = 1.0; 950 for (psS32 loop_y = 1; loop_y < yPoly->nY; loop_y++) {964 for (psS32 loop_y = 1; loop_y < (1 + yPoly->COOL_2D_nY); loop_y++) { 951 965 // 952 966 // For each iteration of the loop, we multiple the (x, y) coefficient
Note:
See TracChangeset
for help on using the changeset viewer.
