Changeset 1374 for trunk/psLib/src/astronomy/psCoord2.c
- Timestamp:
- Aug 3, 2004, 2:55:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astronomy/psCoord2.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psCoord2.c
r1325 r1374 1 // This file contains 1 /** @file psCoord2.c 2 * 3 * @brief Contains basic coordinate transformation definitions and operations 4 * 5 * This file defines the basic types for astronomical coordinate 6 * transformation 7 * 8 * @ingroup CoordinateTransform 9 * 10 * @author George Gusciora, MHPCC 11 * 12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-04 00:55:17 $ 14 * 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 16 */ 2 17 3 18 #include "psType.h" … … 7 22 #include "psFunctions.h" 8 23 9 psGrommit *psGrommitAlloc( const psExposure *exp)10 { 11 psGrommit * grommit = (psGrommit *) psAlloc(sizeof(psGrommit));12 24 psGrommit *psGrommitAlloc( const psExposure *exp ) 25 { 26 psGrommit * grommit = ( psGrommit * ) psAlloc( sizeof( psGrommit ) ); 27 13 28 grommit->latitude = exp->dec; // XXX Is this correct? 14 grommit->sinLat = sin( grommit->latitude);15 grommit->cosLat = cos( grommit->latitude);29 grommit->sinLat = sin( grommit->latitude ); 30 grommit->cosLat = cos( grommit->latitude ); 16 31 grommit->abberationMag = 0.0; 17 32 grommit->height = 0.0; … … 25 40 grommit->longitudeOffset = ra; // XXX Is this correct? 26 41 grommit->siderealTime = 0.0; 27 28 return (grommit);29 } 30 31 void p_psGrommitFree( psGrommit *grommit)32 { 33 psFree( grommit);34 } 35 36 psCell *psCellinFPA( psCell *out,37 const psPlane *coord,38 const psFPA *FPA)39 { 40 psChip * tmpChip = NULL;42 43 return ( grommit ); 44 } 45 46 void p_psGrommitFree( psGrommit *grommit ) 47 { 48 psFree( grommit ); 49 } 50 51 psCell *psCellinFPA( psCell *out, 52 const psPlane *coord, 53 const psFPA *FPA ) 54 { 55 psChip * tmpChip = NULL; 41 56 psCell *tmpCell = NULL; 42 43 tmpChip = psChipinFPA( tmpChip, coord, FPA);44 tmpCell = psCellinChip( tmpCell, coord, tmpChip);45 return (tmpCell);46 } 47 48 49 psChip *psChipinFPA( psChip *out,50 const psPlane *coord,51 const psFPA *FPA)52 { 53 psFPA * tmpChip = NULL;54 55 for ( tmpChip = FPA->chips; tmpChip != NULL; tmpChip++) {56 tmpCoord = psPlaneTransformApply(out, tmpChip->fromFPA, coord);57 58 59 //XXX if (this is the correct chip)60 return(tmpChip);61 }57 58 tmpChip = psChipinFPA( tmpChip, coord, FPA ); 59 tmpCell = psCellinChip( tmpCell, coord, tmpChip ); 60 return ( tmpCell ); 61 } 62 63 64 psChip *psChipinFPA( psChip *out, 65 const psPlane *coord, 66 const psFPA *FPA ) 67 { 68 psFPA * tmpChip = NULL; 69 70 for ( tmpChip = FPA->chips; tmpChip != NULL; tmpChip++ ) { 71 tmpCoord = psPlaneTransformApply( out, tmpChip->fromFPA, coord ); 72 73 74 //XXX if (this is the correct chip) 75 return ( tmpChip ); 76 } 62 77 } 63 78 … … 66 81 p_psCheckValidImageCoords(double x, double y, tmpImage) 67 82 { 68 if ( (x < 0.0) ||69 ( x > (double) tmpImage->numCols) ||70 ( y < 0.0) ||71 ( y > (double) tmpImage->numRows)) {72 return(0);73 }74 return (1);83 if ( ( x < 0.0 ) || 84 ( x > ( double ) tmpImage->numCols ) || 85 ( y < 0.0 ) || 86 ( y > ( double ) tmpImage->numRows ) ) { 87 return ( 0 ); 88 } 89 return ( 1 ); 75 90 } 76 91 … … 88 103 XXX: must deallocate memory. 89 104 *****************************************************************************/ 90 psCell *psCellinChip( psCell *out,91 const psPlane *coord,92 const psChip *chip)93 { 94 psCell * tmpCell = NULL;105 psCell *psCellinChip( psCell *out, 106 const psPlane *coord, 107 const psChip *chip ) 108 { 109 psCell * tmpCell = NULL; 95 110 psReadout *tmpReadout = NULL; 96 111 psPlane *tmpCoord = NULL; 97 98 for (tmpCell = chip->cells; tmpCell != NULL; tmpCell++) { 99 if (tmpCell->readouts != NULL) { 100 tmpReadout = tmpCell->readouts; 101 tmpCoord = psPlaneTransformApply(out, tmpCell->fromChip, coord); 102 if (p_psCheckValidImageCoords(tmpCoord->x, tmpCoord->y, 103 tmpReadout->image)) { 104 return(tmpCell); 105 } 112 113 for ( tmpCell = chip->cells; tmpCell != NULL; tmpCell++ ) { 114 if ( tmpCell->readouts != NULL ) { 115 tmpReadout = tmpCell->readouts; 116 tmpCoord = psPlaneTransformApply( out, tmpCell->fromChip, coord ); 117 if ( p_psCheckValidImageCoords( tmpCoord->x, tmpCoord->y, 118 tmpReadout->image ) ) { 119 return ( tmpCell ); 120 } 121 } 106 122 } 107 } 108 return(NULL); 109 } 110 111 psPlane *psCoordCelltoChip(psPlane *out, 123 return ( NULL ); 124 } 125 126 psPlane *psCoordCelltoChip( psPlane *out, 127 const psPlane *in, 128 const psCell *cell ) 129 { 130 return ( psPlaneTransformApply( out, cell->toChip, in ) ); 131 } 132 133 psPlane *psCoordChipToFPA( psPlane *out, 112 134 const psPlane *in, 113 const psCell *cell) 114 { 115 return(psPlaneTransformApply(out, cell->toChip, in)); 116 } 117 118 psPlane *psCoordChipToFPA(psPlane *out, 135 const psChip *chip ) 136 { 137 return ( psPlaneTransformApply( out, chip->toFPA, in ) ); 138 } 139 140 psPlane *psCoordFPAtoTP( psPlane *out, 141 const psPlane *in, 142 const psFPA *fpa ) 143 { 144 return ( psPlaneTransformApply( out, fpa->toTangentPlane, in ) ); 145 } 146 147 psSphere *psCoordTPtoSky( psSphere *out, 119 148 const psPlane *in, 120 const psChip *chip) 121 { 122 return(psPlaneTransformApply(out, chip->toFPA, in)); 123 } 124 125 psPlane *psCoordFPAtoTP(psPlane *out, 126 const psPlane *in, 127 const psFPA *fpa) 128 { 129 return(psPlaneTransformApply(out, fpa->toTangentPlane, in)); 130 } 131 132 psSphere *psCoordTPtoSky(psSphere *out, 133 const psPlane *in, 134 const psGrommit *grommit) 149 const psGrommit *grommit ) 135 150 {} 136 151 137 152 138 psPlane *psCoordCellToFPA( psPlane *out,139 const psPlane *in,140 const psCell *cell)141 { 142 return (psPlaneTransformApply(out, cell->toFPA, in));153 psPlane *psCoordCellToFPA( psPlane *out, 154 const psPlane *in, 155 const psCell *cell ) 156 { 157 return ( psPlaneTransformApply( out, cell->toFPA, in ) ); 143 158 } 144 159 … … 147 162 // transformation, as well as a few psPlane structs. Can this be implemented 148 163 // better? 149 psSphere *psCoordCelltoSky( psSphere *out,150 const psPlane *in,151 const psCell *cell)152 { 153 psPlane * tmp1 = NULL;164 psSphere *psCoordCelltoSky( psSphere *out, 165 const psPlane *in, 166 const psCell *cell ) 167 { 168 psPlane * tmp1 = NULL; 154 169 psPlane *tmp2 = NULL; 155 psFPA *parFPA = ( cell->parent)->parent;170 psFPA *parFPA = ( cell->parent ) ->parent; 156 171 psGrommit *tmpGrommit = NULL; 157 158 tmp1 = psPlaneTransformApply(tmp1, cell->toFPA, in) 159 tmp2 = psPlaneTransformApply(tmp2, parFPA->toTangentPlane, tmp1) 160 tmpGrommit = psGrommitAlloc(parFPA->exposure) 161 tmp3 = psCoordTPtoSky(out, tmp2, psGrommit); 162 163 psFree(tmp1); 164 psFree(tmp2); 165 psFree(tmpGrommit); 166 167 return(psCoordTPtoSky(out, tmp2, psGrommit); 168 } 169 170 psSphere *psCoordCelltoSkyQuick(psSphere *out, 171 const psPlane *in, 172 const psCell *cell) 173 { 174 psPlane *tmp1 = NULL; 175 176 tmp1 = psPlaneTransformApply(tmp1, cell->toSky, in); 177 178 //XXX: Do something to convert the linear coords in tmp1 to spherical 179 // coords in out. 180 181 free(tmp1) 182 183 return(out); 184 } 185 186 psPlane *psCoordSkytoTP(psPlane *out, 187 const psSphere *in, 188 const psGrommit *grommit) 189 { 190 if (out == NULL) { 191 out = (psPlane *) psAlloc(sizeof(psPlane)); 192 } 193 194 return(out); 195 } 196 197 psPlane *psCoordTPtoFPA(psPlane *out, 198 const psPlane *in, 199 const psFPA *fpa) 200 { 201 return(psPlaneTransformApply(out, fpa->fromTangentPlane, in)); 202 } 203 204 psPlane *psCoordFPAtoChip(psPlane *out, 205 const psPlane *in, 206 const psChip *chip) 207 { 208 return(psPlaneTransformApply(out, chip->fromFPA, in)); 209 } 210 211 212 psPlane *psCoordChiptoCell(psPlane *out, 172 173 tmp1 = psPlaneTransformApply( tmp1, cell->toFPA, in ) 174 tmp2 = psPlaneTransformApply( tmp2, parFPA->toTangentPlane, tmp1 ) 175 tmpGrommit = psGrommitAlloc( parFPA->exposure ) 176 tmp3 = psCoordTPtoSky( out, tmp2, psGrommit ); 177 178 psFree( tmp1 ); 179 psFree( tmp2 ); 180 psFree( tmpGrommit ); 181 182 return ( psCoordTPtoSky( out, tmp2, psGrommit ); 183 } 184 185 psSphere *psCoordCelltoSkyQuick( psSphere *out, 186 const psPlane *in, 187 const psCell *cell ) 188 { 189 psPlane * tmp1 = NULL; 190 191 tmp1 = psPlaneTransformApply( tmp1, cell->toSky, in ); 192 193 //XXX: Do something to convert the linear coords in tmp1 to spherical 194 // coords in out. 195 196 free( tmp1 ) 197 198 return ( out ); 199 } 200 201 psPlane *psCoordSkytoTP( psPlane *out, 202 const psSphere *in, 203 const psGrommit *grommit ) 204 { 205 if ( out == NULL ) { 206 out = ( psPlane * ) psAlloc( sizeof( psPlane ) ); 207 } 208 209 return ( out ); 210 } 211 212 psPlane *psCoordTPtoFPA( psPlane *out, 213 213 const psPlane *in, 214 const psCell *cell) 215 { 216 return(psPlaneTransformApply(out, cell->fromChip, in)); 217 } 218 219 psPlane *psCoordSkytoCell(psPlane *out, 220 const psSphere *in, 221 const psCell *cell) 222 { 223 out = psCoordSkytoTP(out, in, tmpGrommit); 224 out = psCoordTPtoFPA(out, out, whichFPA); 225 out = psCoordFPAtoChip(out, out, whichChip); 226 out = psCoordChiptoCell(out, out, whichCell); 227 228 return(out); 229 } 230 231 psPlane *psCoordSkytoCellQuick(psPlane *out, 232 const psSphere *in, 233 const psCell *cell) 234 { 235 if (out == NULL) { 236 out = (psPlane *) psAlloc(sizeof(psPlane)); 237 } 238 239 return(out); 240 } 241 242 214 const psFPA *fpa ) 215 { 216 return ( psPlaneTransformApply( out, fpa->fromTangentPlane, in ) ); 217 } 218 219 psPlane *psCoordFPAtoChip( psPlane *out, 220 const psPlane *in, 221 const psChip *chip ) 222 { 223 return ( psPlaneTransformApply( out, chip->fromFPA, in ) ); 224 } 225 226 227 psPlane *psCoordChiptoCell( psPlane *out, 228 const psPlane *in, 229 const psCell *cell ) 230 { 231 return ( psPlaneTransformApply( out, cell->fromChip, in ) ); 232 } 233 234 psPlane *psCoordSkytoCell( psPlane *out, 235 const psSphere *in, 236 const psCell *cell ) 237 { 238 out = psCoordSkytoTP( out, in, tmpGrommit ); 239 out = psCoordTPtoFPA( out, out, whichFPA ); 240 out = psCoordFPAtoChip( out, out, whichChip ); 241 out = psCoordChiptoCell( out, out, whichCell ); 242 243 return ( out ); 244 } 245 246 psPlane *psCoordSkytoCellQuick( psPlane *out, 247 const psSphere *in, 248 const psCell *cell ) 249 { 250 if ( out == NULL ) { 251 out = ( psPlane * ) psAlloc( sizeof( psPlane ) ); 252 } 253 254 return ( out ); 255 } 256 257 258
Note:
See TracChangeset
for help on using the changeset viewer.
