File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
LoCameraFiducialMap.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "LoCameraFiducialMap.h"
10 
11 #include "Affine.h"
12 #include "CameraGroundMap.h"
13 #include "CameraSkyMap.h"
14 #include "IString.h"
15 
16 using namespace std;
17 
18 namespace Isis {
27  LoCameraFiducialMap::LoCameraFiducialMap(PvlGroup &inst, const int naifIkCode) {
28  // Get the Instrument label information needed to define the fiducial map for this frame
29  p_naifIkCode = naifIkCode;
30  ReadFiducials(inst);
31 
32  // Set the x-axis direction. The medium camera is reversed.
33  int xdir;
34  if(naifIkCode % 2 == 0) {
35  xdir = -1;
36  }
37  else {
38  xdir = 1;
39  }
40  CreateTrans(xdir);
41  }
42 
43 
53  void LoCameraFiducialMap::ReadFiducials(PvlGroup &inst) {
54 
55  // Try to read the fiducials from the labels
56  try {
57  // Fiducial mapping to define the Focal Plane map
58  PvlKeyword &fSamps = inst["FiducialSamples"];
59  PvlKeyword &fLines = inst["FiducialLines"];
60  PvlKeyword &fXs = inst["FiducialXCoordinates"];
61  PvlKeyword &fYs = inst["FiducialYCoordinates"];
62 
63  for(int i = 0; i < fSamps.size(); i++) {
64  p_fidSamples.push_back(toDouble(fSamps[i]));
65  p_fidLines.push_back(toDouble(fLines[i]));
66  p_fidXCoords.push_back(toDouble(fXs[i]));
67  p_fidYCoords.push_back(toDouble(fYs[i]));
68  }
69  }
70  catch(IException &e) {
71  string msg = "Unable to read fiducial mapping from cube labels - ";
72  msg += "Input cube must be processed in Isis 2 through lofixlabel ";
73  msg += "and converted to Isis with pds2isis";
74  throw IException(e, IException::User, msg, _FILEINFO_);
75  }
76  }
77 
78 
86  void LoCameraFiducialMap::CreateTrans(int xdir) {
87  // Setup focal plane map
88  Affine *fptrans = new Affine();
89 
90  try {
91  fptrans->Solve(&p_fidSamples[0], (double *) &p_fidLines[0],
92  (double *) &p_fidXCoords[0], (double *) &p_fidYCoords[0],
93  p_fidSamples.size());
94 
95  }
96  catch(IException &e) {
97  string msg = "Unable to create fiducial map.";
98  throw IException(IException::User, msg, _FILEINFO_);
99  }
100 
101  // Get the coefficients
102  vector<double> transx;
103  vector<double> transy;
104  transx = fptrans->Coefficients(1);
105  transy = fptrans->Coefficients(2);
106 
107  // Medium camera has a reversed x-axis
108  for(int icoef = 0; icoef < 3; icoef++) {
109  transx[icoef] *= xdir;
110  };
111 
112  // Correct the Affine order - move the constant to the front
113  transx.insert(transx.begin(), transx[2]);
114  transx.pop_back();
115  transy.insert(transy.begin(), transy[2]);
116  transy.pop_back();
117 
118  string icode = "INS" + IString(p_naifIkCode);
119  string icodex = icode + "_TRANSX";
120  string icodey = icode + "_TRANSY";
121  pdpool_c(icodex.c_str(), 3, (double( *)) &transx[0]);
122  pdpool_c(icodey.c_str(), 3, (double( *)) &transy[0]);
123 
124  vector<double> transs;
125  vector<double> transl;
126  transs = fptrans->InverseCoefficients(1);
127  transl = fptrans->InverseCoefficients(2);
128 
129  // Correct the Affine order - move the constant to the front
130  transs.insert(transs.begin(), transs[2]);
131  transs.pop_back();
132  transl.insert(transl.begin(), transl[2]);
133  transl.pop_back();
134 
135  // Medium camera has a reversed x-axis
136  transs[1] *= xdir;
137  transl[1] *= xdir;
138 
139  string icodes = icode + "_ITRANSS";
140  string icodel = icode + "_ITRANSL";
141  pdpool_c(icodes.c_str(), 3, (double( *)) &transs[0]);
142  pdpool_c(icodel.c_str(), 3, (double( *)) &transl[0]);
143  }
144 }
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Affine::Coefficients
std::vector< double > Coefficients(int var)
Return the affine coeffients for the entered variable (1 or 2).
Definition: Affine.cpp:220
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Affine::Solve
void Solve(const double x[], const double y[], const double xp[], const double yp[], int n)
Given a set of coordinate pairs (n >= 3), compute the affine transform that best fits the points.
Definition: Affine.cpp:92
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
std
Namespace for the standard library.
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::Affine
Affine basis function.
Definition: Affine.h:65
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Affine::InverseCoefficients
std::vector< double > InverseCoefficients(int var)
Return the inverse affine coeffients for the entered variable (1 or 2).
Definition: Affine.cpp:237

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:48