9#include "ApolloPanIO.h"
58 for (i=0; i<90; i++) {
67 obs[i].
image[1] = (-21.5 + double(
int(i/2)))*FIDL;
72 obs[i].image[1] -= FIDL/2;
73 else if (
int(i/2) > 22)
74 obs[i].image[1] -= FIDL;
109 if (fiducialNumber < 0 || fiducialNumber > 89)
114 if (fabs(machineX) > 1e20)
117 if (fabs(machineY) > 1e20)
121 obs[fiducialNumber].
mach[0] = machineX;
122 obs[fiducialNumber].
mach[1] = machineY;
142 if (fiducialNumber < 0 || fiducialNumber > 89)
164 double cdot[43][4][6],
175 double adot[2][6],wdot[2];
199 for (i=2,
n=0; i<90; i+=2) {
205 if (
obs[i].flag &&
obs[i+1].flag) {
214 if (
n ==0)
return -1;
221 for (i =0; i<
n; i++) {
248 ndot[i][Isis::isymp(k,l)] += adot[m][k]*adot[m][l];
251 atw[i][k] += adot[0][k]*wdot[0] + adot[1][k]*wdot[1];
263 if (!Isis::choleski_solve(ndot[i],
affines[i].A2I,6,3))
274 for (i=0; i<
n-1; i++) {
278 cdot[i][0][2 ] = 0.0;
279 cdot[i][0][3 ] = 0.0;
280 cdot[i][0][4 ] = 1.0;
281 cdot[i][0][5 ] = 0.0;
283 cdot[i][1][0 ] = 0.0;
284 cdot[i][1][1 ] = 0.0;
287 cdot[i][1][4 ] = 0.0;
288 cdot[i][1][5 ] = 1.0;
292 cdot[i][2][2 ] = 0.0;
293 cdot[i][2][3 ] = 0.0;
294 cdot[i][2][4 ] = 1.0;
295 cdot[i][2][5 ] = 0.0;
297 cdot[i][3][0 ] = 0.0;
298 cdot[i][3][1 ] = 0.0;
301 cdot[i][3][4 ] = 0.0;
302 cdot[i][3][5 ] = 1.0;
306 for (i=0; i<
n-1; i++) {
310 cndot[i][j][k] = 0.0;
314 for (l=0; l<6; l++) {
315 cndot[i][j][k ] += cdot[i][j][l] * ndot[i ][Isis::isymp(l,k)];
316 cndot[i][j][k+6] -= cdot[i][j][l] * ndot[i+1][Isis::isymp(l,k)];
321 for (i=0; i<(
n-1)*4; i++) {
327 for (l=0; l<6; l++) {
328 cxstar[i] -= cdot[j][k][l]*
affines[j ].
A2I[l];
329 cxstar[i] += cdot[j][k][l]*
affines[j+1].
A2I[l];
334 for (i=0; i<14878; i++)
338 for (i=0; i<
n-1; i++) {
341 for (l=0; l<12; l++) {
343 cnct[Isis::isymp(j+4*i,k+4*i)] += cndot[i][j][l] * cdot[i][k][l];
345 cnct[Isis::isymp(j+4*i,k+4*i)] -= cndot[i][j][l] * cdot[i][k][l-6];
350 for (i=0; i<
n-2; i++) {
354 cnct[Isis::isymp(j+i*4,k+4+i*4)] += cndot[i][j][l+6]*cdot[i+1][k][l];
358 Isis::choleski_solve(cnct,cxstar,4*(
n-1),2);
365 for (i=0; i<6; i++) {
367 affines[0].A2I[i] += cxstar[j]*cndot[0][j][i];
371 for (i=1; i<
n-1; i++) {
372 for (j=0; j<6; j++) {
374 affines[i].A2I[j] += cxstar[(i-1)*4+k]*cndot[i-1][k][j+6];
376 affines[i].A2I[j] += cxstar[(i )*4+k]*cndot[i ][k][j ];
381 for (i=0; i<6; i++) {
383 affines[
n-1].A2I[i] += cxstar[4*(
n-2)+j]*cndot[
n-2][j][i+6];
388 for (i=0; i<
n; i++) {
407 double pt1[2], pt2[2],v[2];
409 for (i=0; i<
n; i++) {
424 v[0] = pt1[0] - pt2[0];
425 v[1] = pt1[1] - pt2[1];
428 det = -(pt1[0]*v[0] + pt1[1]*v[1])/(v[0]*v[0]+v[1]*v[1]);
432 angle = atan2((pt1[0]+det*v[0]),(pt1[1]+det*v[1]));
476 v[0] = pt1[0] - pt2[0];
477 v[1] = pt1[1] - pt2[1];
480 det = -(pt1[0]*v[0] + pt1[1]*v[1])/(v[0]*v[0]+v[1]*v[1]);
484 angle = atan((pt1[0]+det*v[0])/(pt1[1]+det*v[1]));
515 for (i=0; i<90; i++) {
558 for (i=0; i<
n-1; i++) {
641 for (i=0; i<
n-1; i++) {
718 for (i=0; i<90; i++) {
720 l = sqrt(
obs[i].residuals[0]*
obs[i].residuals[0] +
721 obs[i].residuals[1]*
obs[i].residuals[1]);
734 for (i=0; i<90; i++) {
736 l = sqrt(
obs[i].residuals[0]*
obs[i].residuals[0] +
737 obs[i].residuals[1]*
obs[i].residuals[1]);
void initialize()
Initilizes member variables in preparation for solving for the interior orientation affines.
double maxR
maximum residual vector length
FidObs obs[90]
array to hold all possible observations of fiducial marks
Affine2D affines[44]
an array of discreet affine transformations pertaining to regions of the image (there can never be mo...
int machine2Image(double *machineX, double *machineY)
This method does an in place (overwriting input) conversion of a cube coordinate (sample,...
int n
the number of affines used to model the image
double meanR
mean of residual vector lenghts
double maxResiduals()
Accessor for the mean (average) of the residual vector lenghts Call after computeInteriorOrienation()...
double stdevResiduals()
Accessor for the standard deviation of the residual vector lenghts Call after computeInteriorOrienati...
ApolloPanIO()
Constructs an ApolloPanIO object.
double meanResiduals()
Accessor for the mean (average) of the residual vector lenghts Call after computeInteriorOrienation()...
void calc_residual_stats()
This method calculates summary statistics for the residual vector lenths for all measured fiducial ma...
int image2Machine(double *imageX, double *imageY)
This method does an in place (overwriting input) conversion of an image coordinate into cube (machine...
~ApolloPanIO()
Destroys the ApolloPanObject.
int fiducialObservation(int fiducialNumber, double machine_x, double machine_y)
This method adds a measurement of the center of an apollo panoramic image fiducial mark for considera...
int clearFiducialObservation(int fiducialNumber)
This method removes a measurement of the center of an apollo panoramic image fiducial mark from consi...
double stdevR
standard deviation of residual vector lengths
int computeInteriorOrienation()
This method leverages all the fiducial obersatvions to caculate a series of affine transformations fo...
This is free and unencumbered software released into the public domain.
Namespace for the standard library.
double rotI[2]
Coefficients to rotate Image coordinates so that the right edge of the region is vertical.
int indeces[2]
indeces of the first and last fiducial marks included in this region
double rotM[2]
Coefficients to rotate machine coordinates so that the right edge of the region is vertical.
double mI
max rotated image y coordinate in the region
double A2I[6]
transformation coefficients to go to image coordinates
double mM
max rotate machine y coordinate in the region
double A2M[6]
transformation coefficients to go to machine coordinates
int flag
flag to tell if the observation has been made
double image[2]
theoretically perfect image coordinates
double mach[2]
machine coordinates of the fiducial mark
double residuals[2]
residuals of the fiducial mark measurement in machine coordinates