10 #define FIDL 5344.186 //nominal line spread of fiducials in 5 micro pixels 11 #define FIDS 22980 //nominal sample spread of fiducials in 5 micron pixels 20 ApolloPanIO::ApolloPanIO() {
27 ApolloPanIO::~ApolloPanIO() {
34 void ApolloPanIO::initialize() {
50 for (i=0; i<90; i++) {
55 obs[i].image[0] = FIDS/2;
57 obs[i].image[0] = -FIDS/2;
59 obs[i].image[1] = (-21.5 + double(
int(i/2)))*FIDL;
64 obs[i].image[1] -= FIDL/2;
65 else if (
int(i/2) > 22)
66 obs[i].image[1] -= FIDL;
68 obs[i].image[1] = -obs[i].image[1];
88 int ApolloPanIO::fiducialObservation(
int fiducialNumber,
double machineX,
double machineY) {
101 if (fiducialNumber < 0 || fiducialNumber > 89)
106 if (fabs(machineX) > 1e20)
109 if (fabs(machineY) > 1e20)
113 obs[fiducialNumber].mach[0] = machineX;
114 obs[fiducialNumber].mach[1] = machineY;
117 obs[fiducialNumber].flag = 1;
132 int ApolloPanIO::clearFiducialObservation(
int fiducialNumber) {
134 if (fiducialNumber < 0 || fiducialNumber > 89)
138 obs[fiducialNumber].flag = 0;
152 int ApolloPanIO::computeInteriorOrienation()
156 double cdot[43][4][6],
167 double adot[2][6],wdot[2];
188 affines[0].indeces[0] =0;
191 for (i=2, n=0; i<90; i+=2) {
197 if (obs[i].flag && obs[i+1].flag) {
198 affines[n ].indeces[1] = i+1;
199 affines[n+1].indeces[0] = i ;
206 if (n ==0)
return -1;
213 for (i =0; i<n; i++) {
222 for (j=affines[i].indeces[0]; j<=affines[i].indeces[1]; j++) {
226 adot[0][0] = obs[j].mach[0];
227 adot[0][1] = obs[j].mach[1];
229 adot[1][2] = obs[j].mach[0];
230 adot[1][3] = obs[j].mach[1];
232 wdot[0] = obs[j].image[0];
233 wdot[1] = obs[j].image[1];
240 ndot[i][Isis::isymp(k,l)] += adot[m][k]*adot[m][l];
243 atw[i][k] += adot[0][k]*wdot[0] + adot[1][k]*wdot[1];
250 affines[i].A2I[j] = atw[i][j];
255 if (!Isis::choleski_solve(ndot[i],affines[i].A2I,6,3))
266 for (i=0; i<n-1; i++) {
268 cdot[i][0][0 ] = obs[affines[i].indeces[1]-1].mach[0];
269 cdot[i][0][1 ] = obs[affines[i].indeces[1]-1].mach[1];
270 cdot[i][0][2 ] = 0.0;
271 cdot[i][0][3 ] = 0.0;
272 cdot[i][0][4 ] = 1.0;
273 cdot[i][0][5 ] = 0.0;
275 cdot[i][1][0 ] = 0.0;
276 cdot[i][1][1 ] = 0.0;
277 cdot[i][1][2 ] = obs[affines[i].indeces[1]-1].mach[0];
278 cdot[i][1][3 ] = obs[affines[i].indeces[1]-1].mach[1];
279 cdot[i][1][4 ] = 0.0;
280 cdot[i][1][5 ] = 1.0;
282 cdot[i][2][0 ] = obs[affines[i].indeces[1] ].mach[0];
283 cdot[i][2][1 ] = obs[affines[i].indeces[1] ].mach[1];
284 cdot[i][2][2 ] = 0.0;
285 cdot[i][2][3 ] = 0.0;
286 cdot[i][2][4 ] = 1.0;
287 cdot[i][2][5 ] = 0.0;
289 cdot[i][3][0 ] = 0.0;
290 cdot[i][3][1 ] = 0.0;
291 cdot[i][3][2 ] = obs[affines[i].indeces[1] ].mach[0];
292 cdot[i][3][3 ] = obs[affines[i].indeces[1] ].mach[1];
293 cdot[i][3][4 ] = 0.0;
294 cdot[i][3][5 ] = 1.0;
298 for (i=0; i<n-1; i++) {
302 cndot[i][j][k] = 0.0;
306 for (l=0; l<6; l++) {
307 cndot[i][j][k ] += cdot[i][j][l] * ndot[i ][Isis::isymp(l,k)];
308 cndot[i][j][k+6] -= cdot[i][j][l] * ndot[i+1][Isis::isymp(l,k)];
313 for (i=0; i<(n-1)*4; i++) {
319 for (l=0; l<6; l++) {
320 cxstar[i] -= cdot[j][k][l]*affines[j ].A2I[l];
321 cxstar[i] += cdot[j][k][l]*affines[j+1].A2I[l];
326 for (i=0; i<14878; i++)
330 for (i=0; i<n-1; i++) {
333 for (l=0; l<12; l++) {
335 cnct[Isis::isymp(j+4*i,k+4*i)] += cndot[i][j][l] * cdot[i][k][l];
337 cnct[Isis::isymp(j+4*i,k+4*i)] -= cndot[i][j][l] * cdot[i][k][l-6];
342 for (i=0; i<n-2; i++) {
346 cnct[Isis::isymp(j+i*4,k+4+i*4)] += cndot[i][j][l+6]*cdot[i+1][k][l];
350 Isis::choleski_solve(cnct,cxstar,4*(n-1),2);
357 for (i=0; i<6; i++) {
359 affines[0].A2I[i] += cxstar[j]*cndot[0][j][i];
363 for (i=1; i<n-1; i++) {
364 for (j=0; j<6; j++) {
366 affines[i].A2I[j] += cxstar[(i-1)*4+k]*cndot[i-1][k][j+6];
368 affines[i].A2I[j] += cxstar[(i )*4+k]*cndot[i ][k][j ];
373 for (i=0; i<6; i++) {
375 affines[n-1].A2I[i] += cxstar[4*(n-2)+j]*cndot[n-2][j][i+6];
380 for (i=0; i<n; i++) {
381 det = affines[i].A2I[0]*affines[i].A2I[3] - affines[i].A2I[1]*affines[i].A2I[2];
383 affines[i].A2M[0] = affines[i].A2I[3]/det;
384 affines[i].A2M[3] = affines[i].A2I[0]/det;
386 affines[i].A2M[1] = -affines[i].A2I[1]/det;
387 affines[i].A2M[2] = -affines[i].A2I[2]/det;
389 affines[i].A2M[4] = - affines[i].A2M[0]*affines[i].A2I[4]
390 - affines[i].A2M[1]*affines[i].A2I[5];
391 affines[i].A2M[5] = - affines[i].A2M[2]*affines[i].A2I[4]
392 - affines[i].A2M[3]*affines[i].A2I[5];
399 double pt1[2], pt2[2],v[2];
401 for (i=0; i<n; i++) {
406 pt1[0] = obs[affines[i].indeces[1]-1].mach[0];
407 pt1[1] = obs[affines[i].indeces[1]-1].mach[1];
409 pt2[0] = obs[affines[i].indeces[1] ].mach[0];
410 pt2[1] = obs[affines[i].indeces[1] ].mach[1];
416 v[0] = pt1[0] - pt2[0];
417 v[1] = pt1[1] - pt2[1];
420 det = -(pt1[0]*v[0] + pt1[1]*v[1])/(v[0]*v[0]+v[1]*v[1]);
424 angle = atan2((pt1[0]+det*v[0]),(pt1[1]+det*v[1]));
429 affines[i].rotM[0] = sin(angle);
430 affines[i].rotM[1] = cos(angle);
435 affines[i].mM = pt1[0]*affines[i].rotM[0] + pt1[1]*affines[i].rotM[1];
448 pt1[0] = affines[i].A2I[0] * obs[affines[i].indeces[1]-1].mach[0] +
449 affines[i].A2I[1] * obs[affines[i].indeces[1]-1].mach[1] +
452 pt1[1] = affines[i].A2I[2] * obs[affines[i].indeces[1]-1].mach[0] +
453 affines[i].A2I[3] * obs[affines[i].indeces[1]-1].mach[1] +
456 pt2[0] = affines[i].A2I[0] * obs[affines[i].indeces[1] ].mach[0] +
457 affines[i].A2I[1] * obs[affines[i].indeces[1] ].mach[1] +
460 pt2[1] = affines[i].A2I[2] * obs[affines[i].indeces[1] ].mach[0] +
461 affines[i].A2I[3] * obs[affines[i].indeces[1] ].mach[1] +
468 v[0] = pt1[0] - pt2[0];
469 v[1] = pt1[1] - pt2[1];
472 det = -(pt1[0]*v[0] + pt1[1]*v[1])/(v[0]*v[0]+v[1]*v[1]);
476 angle = atan((pt1[0]+det*v[0])/(pt1[1]+det*v[1]));
481 affines[i].rotI[0] = sin(angle);
482 affines[i].rotI[1] = cos(angle);
487 affines[i].mI = pt1[0]*affines[i].rotI[0] + pt1[1]*affines[i].rotI[1];
507 for (i=0; i<90; i++) {
511 image2Machine(obs[i].image[0],obs[i].image[1],&pt1[0],&pt1[1]);
513 obs[i].residuals[0] = pt1[0] - obs[i].mach[0];
514 obs[i].residuals[1] = pt1[1] - obs[i].mach[1];
518 calc_residual_stats();
538 int ApolloPanIO::machine2Image(
double *machineX,
double *machineY) {
544 temp = *machineX * affines[n-2].rotM[0] + *machineY * affines[n-2].rotM[1];
546 if (temp > affines[n-2].mM) {
550 for (i=0; i<n-1; i++) {
551 temp = *machineX * affines[i].rotM[0] + *machineY * affines[i].rotM[1];
554 if (temp <= affines[i].mM)
560 npt[0] = affines[i].A2I[0] * *machineX + affines[i].A2I[1] * *machineY + affines[i].A2I[4];
561 npt[1] = affines[i].A2I[2] * *machineX + affines[i].A2I[3] * *machineY + affines[i].A2I[5];
591 int ApolloPanIO::machine2Image(
double machineX,
601 i = machine2Image(imageX,imageY);
621 int ApolloPanIO::image2Machine(
double *imageX,
double *imageY) {
627 temp = *imageX * affines[n-2].rotI[0] + *imageY * affines[n-2].rotI[1];
629 if( temp < affines[n-2].mI)
633 for (i=0; i<n-1; i++) {
634 temp = *imageX * affines[i].rotI[0] + *imageY * affines[i].rotI[1];
637 if( temp >= affines[i].mI)
643 npt[0] = affines[i].A2M[0] * *imageX + affines[i].A2M[1] * *imageY + affines[i].A2M[4];
644 npt[1] = affines[i].A2M[2] * *imageX + affines[i].A2M[3] * *imageY + affines[i].A2M[5];
674 int ApolloPanIO::image2Machine(
double imageX,
690 return image2Machine(machineX,machineY);
699 void ApolloPanIO::calc_residual_stats() {
710 for (i=0; i<90; i++) {
712 l = sqrt(obs[i].residuals[0]*obs[i].residuals[0] +
713 obs[i].residuals[1]*obs[i].residuals[1]);
726 for (i=0; i<90; i++) {
728 l = sqrt(obs[i].residuals[0]*obs[i].residuals[0] +
729 obs[i].residuals[1]*obs[i].residuals[1]);
731 stdevR += (l-meanR)*(l-meanR);
735 stdevR = sqrt(stdevR/(n-1));
746 double ApolloPanIO::stdevResiduals() {
758 double ApolloPanIO::meanResiduals()
769 double ApolloPanIO::maxResiduals()
Namespace for the standard library.
Namespace for ISIS/Bullet specific routines.