Changeset 4579 for trunk/psModules/src/psAstrometry.c
- Timestamp:
- Jul 18, 2005, 3:44:48 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/psAstrometry.c (modified) (47 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/psAstrometry.c
r4577 r4579 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-07-1 8 18:48:29$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-07-19 01:44:48 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "psError.h" 26 26 #include "psConstants.h" 27 #include "psAstronomyErrors.h"27 //#include "psAstronomyErrors.h" 28 28 #include "psMatrix.h" 29 29 #include "psTrace.h" 30 30 #include "psLogMsg.h" 31 31 32 32 33 /***************************************************************************** … … 35 36 psImage. 36 37 *****************************************************************************/ 38 /* 37 39 static psS32 checkValidImageCoords(double x, 38 40 double y, … … 40 42 { 41 43 PS_ASSERT_IMAGE_NON_NULL(tmpImage, 0); 42 44 43 45 if ((x < 0.0) || (x > (double)tmpImage->numCols) || 44 46 (y < 0.0) || (y > (double)tmpImage->numRows)) { 45 47 return (0); 46 48 } 47 49 48 50 return (1); 49 51 } 50 51 52 */ 53 /* 52 54 static void FPAFree(psFPA* fpa) 53 55 { … … 65 67 } 66 68 } 67 69 */ 70 71 /* 68 72 static void chipFree(psChip* chip) 69 73 { … … 75 79 } 76 80 } 77 81 */ 82 83 /* 78 84 static void cellFree(psCell* cell) 79 85 { … … 88 94 } 89 95 } 96 */ 90 97 91 98 static void readoutFree(psReadout* readout) … … 99 106 } 100 107 108 /* 101 109 static void observatoryFree(psObservatory* obs) 102 110 { … … 105 113 } 106 114 } 107 115 */ 116 /* 108 117 static void exposureFree(psExposure* exp) 109 118 { … … 115 124 } 116 125 } 117 126 */ 127 /* 118 128 static void fixedPatternFree(psFixedPattern* fp) 119 129 { … … 122 132 psFree(fp->x[i]); 123 133 } 124 134 125 135 for (psS32 j = 0; j < fp->p_ps_yRows; j++) { 126 136 psFree(fp->y[j]); 127 137 } 128 138 129 139 psFree(fp->x); 130 140 psFree(fp->y); 131 141 } 132 142 } 133 143 */ 134 144 /*****************************************************************************/ 135 145 /* FUNCTION IMPLEMENTATION - PUBLIC */ … … 141 151 * XXX: This assumes that x,y must be of type F64 142 152 */ 153 /* 143 154 psFixedPattern* psFixedPatternAlloc(double x0, 144 double y0,145 double xScale,146 double yScale,147 const psImage *x,148 const psImage *y)149 { 150 psFixedPattern *tmp;151 psS32 i;152 psS32 j;153 154 PS_ASSERT_IMAGE_NON_NULL(x, NULL);155 PS_ASSERT_IMAGE_NON_NULL(y, NULL);156 PS_ASSERT_IMAGE_TYPE(x, PS_TYPE_F64, NULL);157 PS_ASSERT_IMAGE_TYPE(y, PS_TYPE_F64, NULL);158 159 tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));160 // XXX: Is this correct?161 tmp->nX = (x->numCols * x->numRows);162 tmp->nY = (y->numCols * y->numRows);163 tmp->x0 = x0;164 tmp->y0 = y0;165 tmp->xScale = xScale;166 tmp->yScale = yScale;167 tmp->p_ps_xRows = x->numRows;168 tmp->p_ps_xCols = x->numCols;169 tmp->p_ps_yRows = y->numRows;170 tmp->p_ps_yCols = y->numCols;171 tmp->x = (double **) psAlloc(x->numRows * sizeof(double *));172 for (i=0;i<x->numRows;i++) {173 (tmp->x)[i] = (double *) psAlloc(x->numCols * sizeof(double));174 }175 for (i=0;i<x->numRows;i++) {176 for (j=0;j<x->numCols;j++) {177 (tmp->x)[i][j] = x->data.F64[i][j];178 }179 }180 181 tmp->y = (double **) psAlloc(y->numRows * sizeof(double *));182 for (i=0;i<y->numRows;i++) {183 (tmp->y)[i] = (double *) psAlloc(y->numCols * sizeof(double));184 }185 for (i=0;i<y->numRows;i++) {186 for (j=0;j<y->numCols;j++) {187 (tmp->y)[i][j] = y->data.F64[i][j];188 }189 }190 191 psMemSetDeallocator(tmp,(psFreeFunc)fixedPatternFree);192 193 return(tmp);194 } 195 196 155 double y0, 156 double xScale, 157 double yScale, 158 const psImage *x, 159 const psImage *y) 160 { 161 psFixedPattern *tmp; 162 psS32 i; 163 psS32 j; 164 165 PS_ASSERT_IMAGE_NON_NULL(x, NULL); 166 PS_ASSERT_IMAGE_NON_NULL(y, NULL); 167 PS_ASSERT_IMAGE_TYPE(x, PS_TYPE_F64, NULL); 168 PS_ASSERT_IMAGE_TYPE(y, PS_TYPE_F64, NULL); 169 170 tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern)); 171 // XXX: Is this correct? 172 tmp->nX = (x->numCols * x->numRows); 173 tmp->nY = (y->numCols * y->numRows); 174 tmp->x0 = x0; 175 tmp->y0 = y0; 176 tmp->xScale = xScale; 177 tmp->yScale = yScale; 178 tmp->p_ps_xRows = x->numRows; 179 tmp->p_ps_xCols = x->numCols; 180 tmp->p_ps_yRows = y->numRows; 181 tmp->p_ps_yCols = y->numCols; 182 tmp->x = (double **) psAlloc(x->numRows * sizeof(double *)); 183 for (i=0;i<x->numRows;i++) { 184 (tmp->x)[i] = (double *) psAlloc(x->numCols * sizeof(double)); 185 } 186 for (i=0;i<x->numRows;i++) { 187 for (j=0;j<x->numCols;j++) { 188 (tmp->x)[i][j] = x->data.F64[i][j]; 189 } 190 } 191 192 tmp->y = (double **) psAlloc(y->numRows * sizeof(double *)); 193 for (i=0;i<y->numRows;i++) { 194 (tmp->y)[i] = (double *) psAlloc(y->numCols * sizeof(double)); 195 } 196 for (i=0;i<y->numRows;i++) { 197 for (j=0;j<y->numCols;j++) { 198 (tmp->y)[i][j] = y->data.F64[i][j]; 199 } 200 } 201 202 psMemSetDeallocator(tmp,(psFreeFunc)fixedPatternFree); 203 204 return(tmp); 205 } 206 */ 207 /* 197 208 psExposure* psExposureAlloc(double ra, 198 209 double dec, … … 210 221 { 211 222 PS_ASSERT_PTR_NON_NULL(observatory, NULL); 212 223 213 224 psExposure* exp = psAlloc(sizeof(psExposure)); 214 225 *(double *)&exp->ra = ra; … … 223 234 *(float *)&exp->exposureTime = exposureTime; 224 235 *(float *)&exp->wavelength = wavelength; 225 236 226 237 exp->time = psMemIncrRefCounter((psPtr)time); 227 238 exp->observatory = psMemIncrRefCounter((psPtr)observatory); 228 239 229 240 // XXX: how is this value derived? 230 241 *(double *)&exp->lst = psTimeToLMST((psTime*)time,observatory->longitude); … … 235 246 exp->cameraName = NULL; 236 247 exp->telescopeName = NULL; 237 248 238 249 psMemSetDeallocator(exp,(psFreeFunc)exposureFree); 239 250 240 251 return exp; 241 252 } 242 253 */ 254 /* 243 255 psObservatory* psObservatoryAlloc(const char* name, 244 256 double latitude, … … 248 260 { 249 261 psObservatory* obs = psAlloc(sizeof(psObservatory)); 250 262 251 263 if (name == NULL) { 252 264 obs->name = NULL; … … 255 267 strcpy((char*)obs->name, name); 256 268 } 257 269 258 270 *(double *)&obs->latitude = latitude; 259 271 *(double *)&obs->longitude = longitude; 260 272 *(double *)&obs->height = height; 261 273 *(double *)&obs->tlr = tlr; 262 274 263 275 psMemSetDeallocator(obs,(psFreeFunc)observatoryFree); 264 276 265 277 return obs; 266 278 } 267 279 */ 280 /* 268 281 psFPA* psFPAAlloc(psS32 nChips, 269 282 const psExposure* exp) 270 283 { 271 284 PS_ASSERT_INT_NONNEGATIVE(nChips, NULL); 272 285 273 286 psFPA* newFPA = psAlloc(sizeof(psFPA)); 274 287 275 288 // create array of NULL chips of the size nChips 276 289 newFPA->chips = psArrayAlloc(nChips); … … 280 293 } 281 294 newFPA->chips->n = 0; // per requirement 282 295 283 296 newFPA->metadata = NULL; 284 297 newFPA->fromTangentPlane = NULL; 285 298 newFPA->toTangentPlane = NULL; 286 299 newFPA->pattern = NULL; 287 300 288 301 if (exp != NULL) { 289 302 newFPA->exposure = psMemIncrRefCounter((psExposure*)exp); … … 293 306 newFPA->grommit = NULL; 294 307 } 295 308 296 309 newFPA->colorPlus = NULL; 297 310 newFPA->colorMinus = NULL; 298 311 newFPA->projection = NULL; 299 312 300 313 newFPA->rmsX = 0.0f; 301 314 newFPA->rmsY = 0.0f; 302 315 newFPA->chi2 = 0.0f; 303 316 304 317 psMemSetDeallocator(newFPA,(psFreeFunc)FPAFree); 305 318 306 319 return newFPA; 307 320 } 308 321 */ 309 322 /* 310 323 * psChip constructor 311 324 */ 325 /* 312 326 psChip* psChipAlloc(psS32 nCells, 313 327 psFPA *parentFPA) 314 328 { 315 329 PS_ASSERT_INT_NONNEGATIVE(nCells, NULL); 316 330 317 331 psChip* chip = psAlloc(sizeof(psChip)); 318 332 319 333 // create array of NULL psCells 320 334 int n = (nCells > 0) ? nCells : 1; … … 325 339 } 326 340 chip->cells->n = 0; // per requirement 327 341 328 342 *(int*)&chip->row0 = 0; 329 343 *(int*)&chip->col0 = 0; 330 344 331 345 chip->metadata = NULL; 332 346 333 347 chip->toFPA = NULL; 334 348 chip->fromFPA = NULL; 335 349 336 350 chip->parent = parentFPA; 337 351 338 352 psMemSetDeallocator(chip,(psFreeFunc)chipFree); 339 353 340 354 return chip; 341 342 } 343 355 356 } 357 */ 344 358 /* 345 359 * psCell constructor 346 360 */ 361 /* 347 362 psCell* psCellAlloc(psS32 nReadouts, 348 363 psChip* parentChip) 349 364 { 350 365 PS_ASSERT_INT_NONNEGATIVE(nReadouts, NULL); 351 366 352 367 psCell* cell = psAlloc(sizeof(psCell)); 353 368 354 369 // create array of NULL psReadouts 355 370 int n = (nReadouts > 0) ? nReadouts : 1; … … 360 375 } 361 376 cell->readouts->n = 0; // per requirement 362 377 363 378 *(int*)&cell->row0 = 0; 364 379 *(int*)&cell->col0 = 0; 365 380 366 381 cell->metadata = NULL; 367 382 368 383 cell->toChip = NULL; 369 384 cell->fromChip = NULL; … … 371 386 cell->toTP = NULL; 372 387 cell->toSky = NULL; 373 388 374 389 cell->parent = parentChip; 375 390 376 391 psMemSetDeallocator(cell,(psFreeFunc)cellFree); 377 392 378 393 return cell; 379 380 381 } 382 394 395 396 } 397 */ 383 398 psReadout* psReadoutAlloc() 384 399 { … … 402 417 } 403 418 419 /* 404 420 psGrommit* psGrommitAlloc(const psExposure* exp) 405 421 { 406 422 PS_ASSERT_PTR_NON_NULL(exp, NULL); 407 423 408 424 psSphere* polarMotion = p_psTimeGetPoleCoords(exp->time); 409 425 410 426 psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit)); 411 427 412 428 *(double*)&grommit->latitude = exp->observatory->latitude; 413 429 *(double*)&grommit->longitude = exp->observatory->longitude; … … 422 438 *(double*)&grommit->refractB = polarMotion->d; // XXX: need to figure out what to set here too. 423 439 *(double*)&grommit->siderealTime = psTimeToMJD(exp->time); // XXX: this is probably not correct 424 440 425 441 psFree(polarMotion); 426 442 427 443 return (grommit); 428 444 } 429 445 */ 446 /* 430 447 psCell* psCellInFPA(const psPlane* fpaCoord, 431 448 const psFPA* FPA) … … 433 450 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); 434 451 PS_ASSERT_PTR_NON_NULL(FPA, NULL); 435 452 436 453 psChip* tmpChip = NULL; 437 454 psPlane chipCoord; 438 455 psCell* outCell = NULL; 439 456 440 457 // Determine which chip contains the fpaCoords. 441 458 tmpChip = psChipInFPA(fpaCoord, FPA); … … 443 460 return(NULL); 444 461 } 445 462 446 463 // Convert to those chip coordinates. 447 464 psCoordFPAToChip(&chipCoord, fpaCoord, tmpChip); 448 465 449 466 // Determine which cell contains those chip coordinates. 450 467 outCell = psCellInChip(&chipCoord, tmpChip); 451 468 452 469 return (outCell); 453 470 } 454 471 */ 472 /* 455 473 psChip* psChipInFPA(const psPlane* fpaCoord, 456 474 const psFPA* FPA) … … 459 477 PS_ASSERT_PTR_NON_NULL(FPA, NULL); 460 478 PS_ASSERT_PTR_NON_NULL(FPA->chips, NULL); 461 479 462 480 psArray* chips = FPA->chips; 463 481 psS32 nChips = chips->n; 464 482 psPlane chipCoord; 465 483 psCell *tmpCell = NULL; 466 484 467 485 // Loop through every chip in this FPA. Convert the original FPA 468 486 // coordinates to chip coordinates for that chip. Then, determine if any 469 487 // cells in that chip contain those chip coordinates. 470 488 471 489 for (psS32 i = 0; i < nChips; i++) { 472 490 psChip* tmpChip = chips->data[i]; 473 491 PS_ASSERT_PTR_NON_NULL(tmpChip, NULL); 474 492 PS_ASSERT_PTR_NON_NULL(tmpChip->fromFPA, NULL); 475 493 476 494 psPlaneTransformApply(&chipCoord, tmpChip->fromFPA, fpaCoord); 477 495 478 496 tmpCell = psCellInChip(&chipCoord, tmpChip); 479 497 if (tmpCell != NULL) { … … 481 499 } 482 500 } 483 501 484 502 // XXX: Print warning here? 485 503 return (NULL); 486 504 } 487 505 */ 506 /* 488 507 psCell* psCellInChip(const psPlane* chipCoord, 489 508 const psChip* chip) … … 491 510 PS_ASSERT_PTR_NON_NULL(chipCoord, NULL); 492 511 PS_ASSERT_PTR_NON_NULL(chip, NULL); 493 512 494 513 psPlane cellCoord; 495 514 psArray* cells; 496 515 497 516 cells = chip->cells; 498 517 if (cells == NULL) { 499 518 return NULL; 500 519 } 501 520 502 521 // We loop over each cell in the chip. We transform the chipCoord into 503 522 // a cellCoord for that cell and determine if that cellCoord is valid. 504 523 // If so, then we return that cell. 505 524 506 525 for (psS32 i = 0; i < cells->n; i++) { 507 526 psCell* tmpCell = (psCell* ) cells->data[i]; … … 509 528 PS_ASSERT_PTR_NON_NULL(tmpCell->fromChip, NULL); 510 529 psArray* readouts = tmpCell->readouts; 511 530 512 531 if (readouts != NULL) { 513 532 for (psS32 j = 0; j < readouts->n; j++) { 514 533 psReadout* tmpReadout = readouts->data[j]; 515 534 PS_ASSERT_READOUT_NON_NULL(tmpReadout, NULL); 516 535 517 536 psPlaneTransformApply(&cellCoord, 518 537 tmpCell->fromChip, 519 538 chipCoord); 520 539 521 540 if (checkValidImageCoords(cellCoord.x, 522 541 cellCoord.y, … … 527 546 } 528 547 } 529 548 530 549 return (NULL); 531 550 } 532 551 */ 552 /* 533 553 psPlane* psCoordCellToChip(psPlane* outCoord, 534 554 const psPlane* inCoord, … … 537 557 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 538 558 PS_ASSERT_PTR_NON_NULL(cell, NULL); 539 559 540 560 return (psPlaneTransformApply(outCoord, cell->toChip, inCoord)); 541 561 } 542 562 */ 563 /* 543 564 psPlane* psCoordChipToFPA(psPlane* outCoord, 544 565 const psPlane* inCoord, … … 547 568 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 548 569 PS_ASSERT_PTR_NON_NULL(chip, NULL); 549 570 550 571 return (psPlaneTransformApply(outCoord, chip->toFPA, inCoord)); 551 572 } 552 573 */ 574 /* 553 575 psPlane* psCoordFPAToTP(psPlane* outCoord, 554 576 const psPlane* inCoord, … … 559 581 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 560 582 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 561 583 562 584 return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, 563 585 color, magnitude)); 564 586 } 565 587 */ 566 588 /***************************************************************************** 567 589 XXX: What about units for the (x,y) coords? 568 590 *****************************************************************************/ 591 /* 569 592 psSphere* psCoordTPToSky(psSphere* outSphere, 570 593 const psPlane* tpCoord, … … 573 596 PS_ASSERT_PTR_NON_NULL(tpCoord, NULL); 574 597 PS_ASSERT_PTR_NON_NULL(grommit, NULL); 575 598 576 599 if (outSphere == NULL) { 577 600 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 578 601 } 579 602 580 603 // XXX: this was done by a SLALIB call -- needs to be reimplemented 581 604 psWarning("Warning! psCoordTPToSky functionality is no longer implemented"); 582 / *slaAopqk(tpCoord->x, tpCoord->y, (double*)grommit,583 &AOB, &ZOB, &HOB, &outSphere->r, &outSphere->d); */584 605 // slaAopqk(tpCoord->x, tpCoord->y, (double*)grommit, 606 // &AOB, &ZOB, &HOB, &outSphere->r, &outSphere->d); 607 585 608 return (outSphere); 586 609 } 587 610 */ 611 /* 588 612 psPlane* psCoordCellToFPA(psPlane* fpaCoord, 589 613 const psPlane* cellCoord, … … 592 616 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); 593 617 PS_ASSERT_PTR_NON_NULL(cell, NULL); 594 618 595 619 return (psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord)); 596 620 } 597 621 */ 622 /* 598 623 psSphere* psCoordCellToSky(psSphere* skyCoord, 599 624 const psPlane* cellCoord, … … 609 634 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->toTangentPlane, NULL); 610 635 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->exposure, NULL); 611 636 612 637 psPlane* fpaCoord = NULL; 613 638 psPlane* tpCoord = NULL; 614 639 psFPA* parFPA = (cell->parent)->parent; 615 640 psGrommit* tmpGrommit = NULL; 616 641 617 642 // Convert the input cell coordinates to FPA coordinates. 618 643 fpaCoord = psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord); 619 644 620 645 // Convert the FPA coordinates to tangent plane Coordinates. 621 646 tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, 622 647 fpaCoord, color, magnitude); 623 648 624 649 // Generate a grommit for this FPA. 625 650 tmpGrommit = psGrommitAlloc(parFPA->exposure); 626 651 627 652 // Convert the tangent plane Coordinates to sky coordinates. 628 653 skyCoord = psCoordTPToSky(skyCoord, tpCoord, tmpGrommit); 629 654 630 655 psFree(fpaCoord); 631 656 psFree(tpCoord); 632 657 psFree(tmpGrommit); 633 658 634 659 return(skyCoord); 635 660 } 636 661 662 */ 663 /* 637 664 psSphere* psCoordCellToSkyQuick(psSphere* outSphere, 638 665 const psPlane* cellCoord, … … 650 677 "WARNING: psCoordCellToSkyQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used."); 651 678 } 652 679 653 680 psPlane *tpCoord = NULL; 654 681 psChip *chip = cell->parent; 655 682 psFPA *FPA = chip->parent; 656 683 psProjectionType oldProjectionType; 657 684 658 685 if (outSphere == NULL) { 659 686 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 660 687 } 661 688 662 689 // Determine the tangent plane coordinates. 663 690 tpCoord = psPlaneTransformApply(NULL, cell->toTP, cellCoord); 664 691 665 692 // Save the old projection type and set the new projection type to TAN. 666 693 oldProjectionType = FPA->projection->type; 667 694 FPA->projection->type = PS_PROJ_TAN; 668 695 669 696 // Deproject the tangent plane coordinates a sphere. 670 697 outSphere = psDeproject(tpCoord, FPA->projection); 671 698 672 699 // Restore old projection type. Free memory. 673 700 FPA->projection->type = oldProjectionType; 674 701 psFree(tpCoord); 675 702 676 703 return (outSphere); 677 704 } 705 */ 678 706 679 707 /***************************************************************************** 680 708 XXX: What about units for the (x,y) coords? 681 709 *****************************************************************************/ 710 /* 682 711 psPlane* psCoordSkyToTP(psPlane* tpCoord, 683 712 const psSphere* in, … … 686 715 PS_ASSERT_PTR_NON_NULL(in, NULL); 687 716 PS_ASSERT_PTR_NON_NULL(grommit, NULL); 688 717 689 718 // char* type = "RA"; 690 719 691 720 if (tpCoord == NULL) { 692 721 tpCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 693 722 } 694 723 695 724 // XXX: this was done by a SLALIB call -- needs to be reimplemented 696 725 psWarning("Warning! psCoordSkyToTP functionality is no longer implemented"); 697 / * slaOapqk(type, in->r, in->d, (double*)grommit, &tpCoord->x, &tpCoord->y); */698 726 // slaOapqk(type, in->r, in->d, (double*)grommit, &tpCoord->x, &tpCoord->y); 727 699 728 return(tpCoord); 700 729 } 701 702 730 */ 731 /* 703 732 psPlane* psCoordTPToFPA(psPlane* fpaCoord, 704 733 const psPlane* tpCoord, … … 710 739 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 711 740 PS_ASSERT_PTR_NON_NULL(fpa->fromTangentPlane, NULL); 712 741 713 742 return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane, 714 743 tpCoord, color, magnitude)); 715 744 } 716 745 */ 746 /* 717 747 psPlane* psCoordFPAToChip(psPlane* chipCoord, 718 748 const psPlane* fpaCoord, … … 722 752 PS_ASSERT_PTR_NON_NULL(chip, NULL); 723 753 PS_ASSERT_PTR_NON_NULL(chip->fromFPA, NULL); 724 754 725 755 chipCoord = psPlaneTransformApply(chipCoord, chip->fromFPA, fpaCoord); 726 756 return(chipCoord); 727 757 } 728 758 */ 759 /* 729 760 psPlane* psCoordChipToCell(psPlane* cellCoord, 730 761 const psPlane* chipCoord, … … 734 765 PS_ASSERT_PTR_NON_NULL(cell, NULL); 735 766 PS_ASSERT_PTR_NON_NULL(cell->fromChip, NULL); 736 767 737 768 cellCoord = psPlaneTransformApply(cellCoord, cell->fromChip, chipCoord); 738 769 return(cellCoord); 739 770 } 740 771 */ 772 /* 741 773 psPlane* psCoordSkyToCell(psPlane* cellCoord, 742 774 const psSphere* skyCoord, … … 750 782 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 751 783 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->grommit, NULL); 752 784 753 785 psChip *parChip = cell->parent; 754 786 psFPA *parFPA = parChip->parent; 755 787 psGrommit* grommit = parFPA->grommit; 756 788 757 789 // Convert the skyCoords to tangent plane coords. 758 790 psPlane *tpCoord = psCoordSkyToTP(tpCoord, skyCoord, grommit); 759 791 760 792 // Convert the tangent plane coords to FPA coords. 761 793 psPlane *fpaCoord = psCoordTPToFPA(fpaCoord, tpCoord, color, 762 794 magnitude, parFPA); 763 795 764 796 // Convert the FPA coords to chip coords. 765 797 psPlane *chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, parChip); 766 798 767 799 // Convert the chip coords to cell coords. 768 800 cellCoord = psCoordChipToCell(cellCoord, chipCoord, cell); 769 801 770 802 psFree(tpCoord); 771 803 psFree(fpaCoord); 772 804 psFree(chipCoord); 773 805 774 806 return (cellCoord); 775 807 } 776 808 */ 809 /* 777 810 psPlane* psCoordSkyToCellQuick(psPlane* cellCoord, 778 811 const psSphere* skyCoord, … … 790 823 "WARNING: psCoordSkyToCellQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used."); 791 824 } 792 825 793 826 psPlane *tpCoord = NULL; 794 827 psChip *whichChip = cell->parent; … … 796 829 psProjectionType oldProjectionType; 797 830 psPlaneTransform *TPtoCell = NULL; 798 831 799 832 // Save the old projection type and set the new projection type to TAN. 800 833 oldProjectionType = whichFPA->projection->type; 801 834 whichFPA->projection->type = PS_PROJ_TAN; 802 835 803 836 if (cellCoord == NULL) { 804 837 cellCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 805 838 } 806 839 807 840 tpCoord = psProject(skyCoord, whichFPA->projection); 808 841 809 842 // generate an error if cell->toTP is not linear. 810 843 if (0 == p_psIsProjectionLinear(cell->toTP)) { … … 813 846 "cell to tangent plane"); 814 847 } 815 848 816 849 TPtoCell = p_psPlaneTransformLinearInvert(cell->toTP); 817 850 cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord); 818 851 819 852 // Restore old projection type. Free memory. 820 853 whichFPA->projection->type = oldProjectionType; … … 822 855 return (cellCoord); 823 856 } 824 825 826 857 */ 858 859
Note:
See TracChangeset
for help on using the changeset viewer.
