Isis 3 Programmer Reference
CameraFocalPlaneMap.cpp
Go to the documentation of this file.
1 
23 #include "CameraFocalPlaneMap.h"
24 
25 #include <cmath>
26 
27 #include <QDebug>
28 #include <QVector>
29 
30 #include "Affine.h"
31 #include "Camera.h"
32 #include "Spice.h"
33 
34 namespace Isis {
41  CameraFocalPlaneMap::CameraFocalPlaneMap(Camera *parent, const int naifIkCode) {
42  Init(parent, naifIkCode);
43  }
44 
45 
52  Init(0, naifIkCode);
53  }
54 
55 
70  p_camera = parent;
71 
72  p_transx[0] = affine.Coefficients(1)[2];
73  p_transx[1] = affine.Coefficients(1)[0];
74  p_transx[2] = affine.Coefficients(1)[1];
75 
76  p_transy[0] = affine.Coefficients(2)[2];
77  p_transy[1] = affine.Coefficients(2)[0];
78  p_transy[2] = affine.Coefficients(2)[1];
79 
80  p_itranss[0] = affine.InverseCoefficients(1)[2];
81  p_itranss[1] = affine.InverseCoefficients(1)[0];
82  p_itranss[2] = affine.InverseCoefficients(1)[1];
83 
84  p_itransl[0] = affine.InverseCoefficients(2)[2];
85  p_itransl[1] = affine.InverseCoefficients(2)[0];
86  p_itransl[2] = affine.InverseCoefficients(2)[1];
87 
88  if (parent != 0) {
90  }
91  }
92 
93 
99  }
100 
101 
108  void CameraFocalPlaneMap::Init(Camera *parent, const int naifIkCode) {
110  p_detectorLineOrigin = 0.0;
112  p_detectorLineOffset = 0.0;
113  p_camera = parent;
114 
115  if (naifIkCode != 0) {
116  QString xkey = "INS" + toString(naifIkCode) + "_TRANSX";
117  QString ykey = "INS" + toString(naifIkCode) + "_TRANSY";
118  QString ixkey = "INS" + toString(naifIkCode) + "_ITRANSS";
119  QString iykey = "INS" + toString(naifIkCode) + "_ITRANSL";
120  for (int i = 0; i < 3; ++i) {
121  p_transx[i] = parent->getDouble(xkey, i);
122  p_transy[i] = parent->getDouble(ykey, i);
123  p_itranss[i] = parent->getDouble(ixkey, i);
124  p_itransl[i] = parent->getDouble(iykey, i);
125  }
126  }
127  else {
128  QString xkey = "IDEAL_TRANSX";
129  QString ykey = "IDEAL_TRANSY";
130  QString ixkey = "IDEAL_TRANSS";
131  QString iykey = "IDEAL_TRANSL";
132  for (int i = 0; i < 3; ++i) {
133  p_transx[i] = parent->getDouble(xkey, i);
134  p_transy[i] = parent->getDouble(ykey, i);
135  p_itranss[i] = parent->getDouble(ixkey, i);
136  p_itransl[i] = parent->getDouble(iykey, i);
137  }
138  }
139 
140  if (parent != 0) {
141  p_camera->SetFocalPlaneMap(this);
142  }
143  }
144 
145 
159  bool CameraFocalPlaneMap::SetFocalPlane(const double dx, const double dy) {
160  p_focalPlaneX = dx;
161  p_focalPlaneY = dy;
162 
163  p_centeredDetectorSample = p_itranss[0] + (p_itranss[1] * dx) + (p_itranss[2] * dy);
164  p_centeredDetectorLine = p_itransl[0] + (p_itransl[1] * dx) + (p_itransl[2] * dy);
166  return true;
167  }
168 
169 
180  bool CameraFocalPlaneMap::SetDetector(const double sample, const double line) {
181  p_detectorSample = sample;
182  p_detectorLine = line;
183  ComputeCentered();
186  return true;
187  }
188 
189 
197 // CameraFocalPlaneMap::FocalPlaneXDependencyType CameraFocalPlaneMap::FocalPlaneXDependency() {
199  if (p_transx[1] > p_transx[2]) {
200  return Sample;
201  }
202  else {
203  return Line;
204  }
205  }
206 
207 
218  double magCoef1 = fabs(p_transx[1]);
219  double magCoef2 = fabs(p_transx[2]);
220 
221  if (magCoef1 > magCoef2) {
222  return (magCoef1 / p_transx[1]);
223  }
224  else {
225  return (magCoef2 / p_transx[2]);
226  }
227  }
228 
229 
240  double magCoef1 = fabs(p_transy[1]);
241  double magCoef2 = fabs(p_transy[2]);
242 
243  if (magCoef1 > magCoef2) {
244  return (magCoef1 / p_transy[1]);
245  }
246  else {
247  return (magCoef2 / p_transy[2]);
248  }
249  }
250 
251 
256  return p_focalPlaneX;
257  }
258 
259 
264  return p_focalPlaneY;
265  }
266 
267 
272  return p_detectorSample;
273  }
274 
275 
280  return p_detectorLine;
281  }
282 
283 
289  }
290 
291 
296  return p_centeredDetectorLine;
297  }
298 
299 
309  void CameraFocalPlaneMap::SetDetectorOrigin(const double sample, const double line) {
310  p_detectorSampleOrigin = sample;
311  p_detectorLineOrigin = line;
312  }
313 
314 
319  return p_detectorLineOrigin;
320  }
321 
322 
327  return p_detectorSampleOrigin;
328  }
329 
330 
340  void CameraFocalPlaneMap::SetDetectorOffset(const double sampleOffset,
341  const double lineOffset) {
342  p_detectorSampleOffset = sampleOffset;
343  p_detectorLineOffset = lineOffset;
344  }
345 
346 
351  return p_detectorLineOffset;
352  }
353 
354 
359  return p_detectorSampleOffset;
360  }
361 
362 
369  for (int i=0; i<3; ++i) {
370  p_itransl[i] = transL[i];
371  }
372  }
373 
374 
381  for (int i=0; i<3; ++i) {
382  p_itranss[i] = transS[i];
383  }
384  }
385 
386 
393  for (int i=0; i<3; ++i) {
394  p_transx[i] = transX[i];
395  }
396  }
397 
398 
405  for (int i=0; i<3; ++i) {
406  p_transy[i] = transY[i];
407  }
408  }
409 
410 
414  const double *CameraFocalPlaneMap::TransX() const{
415  return p_transx;
416  }
417 
418 
422  const double *CameraFocalPlaneMap::TransY() const{
423  return p_transy;
424  }
425 
426 
430  const double *CameraFocalPlaneMap::TransS() const{
431  return p_itranss;
432  }
433 
434 
438  const double *CameraFocalPlaneMap::TransL() const{
439  return p_itransl;
440  }
441 
442 
447  }
448 
449 
454  }
455 
456 }
457 
double p_detectorLine
line value of the detector
double p_detectorSampleOrigin
The origin sample of the detector.
const double * TransX() const
void SetTransY(const QVector< double > transY)
Set the affine coefficients for converting detector (sample,line) to a distorted Y.
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute detector position (sample,line) from focal plane coordinates.
virtual ~CameraFocalPlaneMap()
Destructor.
void ComputeCentered()
Convenience method to center detector origin (use when inheriting)
void SetTransL(const QVector< double > transL)
Set the affine coefficients for converting destorted (x,y) to a detector Line.
double p_focalPlaneX
x value of focal plane coordinate
The x value of the focal plane maps to a sample.
double p_itranss[3]
The x transition from distorted to detector.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
double p_transx[3]
The x transition from detector to distorted.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
virtual bool SetDetector(const double sample, const double line)
Compute distorted focal plane coordinate from detector position (sampel,line)
double p_focalPlaneY
y value of focal plane coordinate
const double * TransS() const
double SignMostSigX()
Return the sign of the p_transx coefficient with the greatest magnitude.
double SignMostSigY()
Return the sign of the p_transy coefficient with the greatest magnitude.
std::vector< double > Coefficients(int var)
Return the affine coeffients for the entered variable (1 or 2).
Definition: Affine.cpp:234
Affine basis function.
Definition: Affine.h:80
double p_detectorLineOffset
Offset of the detector origin line from the average.
void SetTransX(const QVector< double > transX)
Set the affine coefficients for converting detector (sample,line) to a distorted X.
void SetTransS(const QVector< double > transS)
Set the affine coefficients for converting destorted (x,y) to a detector Sample.
void SetFocalPlaneMap(CameraFocalPlaneMap *map)
Sets the Focal Plane Map.
Definition: Camera.cpp:2369
void ComputeUncentered()
Convenience method to center detector origin (use when inheriting)
void Init(Camera *parent, const int naifIkCode)
Initialize the focal plane map to its default state.
CameraFocalPlaneMap(Camera *parent, const int naifIkCode)
Construct mapping between detectors and focal plane x/y.
double p_detectorSampleOffset
offset of the detector origin sample from the average
const double * TransL() const
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
std::vector< double > InverseCoefficients(int var)
Return the inverse affine coeffients for the entered variable (1 or 2).
Definition: Affine.cpp:251
double p_centeredDetectorSample
Detector sample position.
double p_detectorLineOrigin
The origin line of the detector.
double p_centeredDetectorLine
Detector line position.
const double * TransY() const
double p_detectorSample
sample value of the detector
The x value of the focal plane maps to a line.
Camera * p_camera
Camera of the image.
double p_itransl[3]
The y transition from distorted to detector.
double p_transy[3]
The y transition from detector to distorted.
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:963
int FocalPlaneXDependency()
Return the focal plane x dependency variable.