Isis 3 Programmer Reference
CameraFocalPlaneMap.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "CameraFocalPlaneMap.h"
8 
9 #include <cmath>
10 
11 #include <QDebug>
12 #include <QVector>
13 
14 #include "Affine.h"
15 #include "Camera.h"
16 #include "Spice.h"
17 
18 namespace Isis {
25  CameraFocalPlaneMap::CameraFocalPlaneMap(Camera *parent, const int naifIkCode) {
26  Init(parent, naifIkCode);
27  }
28 
29 
36  Init(0, naifIkCode);
37  }
38 
39 
54  p_camera = parent;
55 
56  p_transx[0] = affine.Coefficients(1)[2];
57  p_transx[1] = affine.Coefficients(1)[0];
58  p_transx[2] = affine.Coefficients(1)[1];
59 
60  p_transy[0] = affine.Coefficients(2)[2];
61  p_transy[1] = affine.Coefficients(2)[0];
62  p_transy[2] = affine.Coefficients(2)[1];
63 
64  p_itranss[0] = affine.InverseCoefficients(1)[2];
65  p_itranss[1] = affine.InverseCoefficients(1)[0];
66  p_itranss[2] = affine.InverseCoefficients(1)[1];
67 
68  p_itransl[0] = affine.InverseCoefficients(2)[2];
69  p_itransl[1] = affine.InverseCoefficients(2)[0];
70  p_itransl[2] = affine.InverseCoefficients(2)[1];
71 
72  if (parent != 0) {
74  }
75  }
76 
77 
83  }
84 
85 
92  void CameraFocalPlaneMap::Init(Camera *parent, const int naifIkCode) {
97  p_camera = parent;
98 
99  if (naifIkCode != 0) {
100  QString xkey = "INS" + toString(naifIkCode) + "_TRANSX";
101  QString ykey = "INS" + toString(naifIkCode) + "_TRANSY";
102  QString ixkey = "INS" + toString(naifIkCode) + "_ITRANSS";
103  QString iykey = "INS" + toString(naifIkCode) + "_ITRANSL";
104  for (int i = 0; i < 3; ++i) {
105  p_transx[i] = parent->getDouble(xkey, i);
106  p_transy[i] = parent->getDouble(ykey, i);
107  p_itranss[i] = parent->getDouble(ixkey, i);
108  p_itransl[i] = parent->getDouble(iykey, i);
109  }
110  }
111  else {
112  QString xkey = "IDEAL_TRANSX";
113  QString ykey = "IDEAL_TRANSY";
114  QString ixkey = "IDEAL_TRANSS";
115  QString iykey = "IDEAL_TRANSL";
116  for (int i = 0; i < 3; ++i) {
117  p_transx[i] = parent->getDouble(xkey, i);
118  p_transy[i] = parent->getDouble(ykey, i);
119  p_itranss[i] = parent->getDouble(ixkey, i);
120  p_itransl[i] = parent->getDouble(iykey, i);
121  }
122  }
123 
124  if (parent != 0) {
125  p_camera->SetFocalPlaneMap(this);
126  }
127  }
128 
129 
143  bool CameraFocalPlaneMap::SetFocalPlane(const double dx, const double dy) {
144  p_focalPlaneX = dx;
145  p_focalPlaneY = dy;
146 
147  p_centeredDetectorSample = p_itranss[0] + (p_itranss[1] * dx) + (p_itranss[2] * dy);
148  p_centeredDetectorLine = p_itransl[0] + (p_itransl[1] * dx) + (p_itransl[2] * dy);
150  return true;
151  }
152 
153 
164  bool CameraFocalPlaneMap::SetDetector(const double sample, const double line) {
165  p_detectorSample = sample;
166  p_detectorLine = line;
167  ComputeCentered();
170  return true;
171  }
172 
173 
181 // CameraFocalPlaneMap::FocalPlaneXDependencyType CameraFocalPlaneMap::FocalPlaneXDependency() {
183  if (p_transx[1] > p_transx[2]) {
184  return Sample;
185  }
186  else {
187  return Line;
188  }
189  }
190 
191 
202  double magCoef1 = fabs(p_transx[1]);
203  double magCoef2 = fabs(p_transx[2]);
204 
205  if (magCoef1 > magCoef2) {
206  return (magCoef1 / p_transx[1]);
207  }
208  else {
209  return (magCoef2 / p_transx[2]);
210  }
211  }
212 
213 
224  double magCoef1 = fabs(p_transy[1]);
225  double magCoef2 = fabs(p_transy[2]);
226 
227  if (magCoef1 > magCoef2) {
228  return (magCoef1 / p_transy[1]);
229  }
230  else {
231  return (magCoef2 / p_transy[2]);
232  }
233  }
234 
235 
240  return p_focalPlaneX;
241  }
242 
243 
248  return p_focalPlaneY;
249  }
250 
251 
256  return p_detectorSample;
257  }
258 
259 
264  return p_detectorLine;
265  }
266 
267 
273  }
274 
275 
280  return p_centeredDetectorLine;
281  }
282 
283 
293  void CameraFocalPlaneMap::SetDetectorOrigin(const double sample, const double line) {
294  p_detectorSampleOrigin = sample;
295  p_detectorLineOrigin = line;
296  }
297 
298 
303  return p_detectorLineOrigin;
304  }
305 
306 
311  return p_detectorSampleOrigin;
312  }
313 
314 
324  void CameraFocalPlaneMap::SetDetectorOffset(const double sampleOffset,
325  const double lineOffset) {
326  p_detectorSampleOffset = sampleOffset;
327  p_detectorLineOffset = lineOffset;
328  }
329 
330 
335  return p_detectorLineOffset;
336  }
337 
338 
343  return p_detectorSampleOffset;
344  }
345 
346 
353  for (int i=0; i<3; ++i) {
354  p_itransl[i] = transL[i];
355  }
356  }
357 
358 
365  for (int i=0; i<3; ++i) {
366  p_itranss[i] = transS[i];
367  }
368  }
369 
370 
377  for (int i=0; i<3; ++i) {
378  p_transx[i] = transX[i];
379  }
380  }
381 
382 
389  for (int i=0; i<3; ++i) {
390  p_transy[i] = transY[i];
391  }
392  }
393 
394 
398  const double *CameraFocalPlaneMap::TransX() const{
399  return p_transx;
400  }
401 
402 
406  const double *CameraFocalPlaneMap::TransY() const{
407  return p_transy;
408  }
409 
410 
414  const double *CameraFocalPlaneMap::TransS() const{
415  return p_itranss;
416  }
417 
418 
422  const double *CameraFocalPlaneMap::TransL() const{
423  return p_itransl;
424  }
425 
426 
431  }
432 
433 
438  }
439 
440 }
441 
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::CameraFocalPlaneMap::SetTransS
void SetTransS(const QVector< double > transS)
Set the affine coefficients for converting destorted (x,y) to a detector Sample.
Definition: CameraFocalPlaneMap.cpp:364
Isis::CameraFocalPlaneMap::DetectorSampleOffset
double DetectorSampleOffset() const
Definition: CameraFocalPlaneMap.cpp:342
Isis::CameraFocalPlaneMap::FocalPlaneY
double FocalPlaneY() const
Definition: CameraFocalPlaneMap.cpp:247
Isis::CameraFocalPlaneMap::p_focalPlaneY
double p_focalPlaneY
y value of focal plane coordinate
Definition: CameraFocalPlaneMap.h:143
Isis::CameraFocalPlaneMap::p_detectorLineOffset
double p_detectorLineOffset
Offset of the detector origin line from the average.
Definition: CameraFocalPlaneMap.h:149
Isis::CameraFocalPlaneMap::p_detectorLineOrigin
double p_detectorLineOrigin
The origin line of the detector.
Definition: CameraFocalPlaneMap.h:139
Isis::CameraFocalPlaneMap::SetTransX
void SetTransX(const QVector< double > transX)
Set the affine coefficients for converting detector (sample,line) to a distorted X.
Definition: CameraFocalPlaneMap.cpp:376
Isis::CameraFocalPlaneMap::Init
void Init(Camera *parent, const int naifIkCode)
Initialize the focal plane map to its default state.
Definition: CameraFocalPlaneMap.cpp:92
Isis::CameraFocalPlaneMap::CameraFocalPlaneMap
CameraFocalPlaneMap(Camera *parent, const int naifIkCode)
Construct mapping between detectors and focal plane x/y.
Definition: CameraFocalPlaneMap.cpp:25
Isis::CameraFocalPlaneMap::SignMostSigX
double SignMostSigX()
Return the sign of the p_transx coefficient with the greatest magnitude.
Definition: CameraFocalPlaneMap.cpp:201
Isis::CameraFocalPlaneMap::p_camera
Camera * p_camera
Camera of the image.
Definition: CameraFocalPlaneMap.h:137
Isis::CameraFocalPlaneMap::DetectorLine
double DetectorLine() const
Definition: CameraFocalPlaneMap.cpp:263
Isis::CameraFocalPlaneMap::SetDetectorOffset
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Definition: CameraFocalPlaneMap.cpp:324
Isis::CameraFocalPlaneMap::ComputeCentered
void ComputeCentered()
Convenience method to center detector origin (use when inheriting)
Definition: CameraFocalPlaneMap.cpp:428
Isis::CameraFocalPlaneMap::p_itransl
double p_itransl[3]
The y transition from distorted to detector.
Definition: CameraFocalPlaneMap.h:155
Isis::CameraFocalPlaneMap::ComputeUncentered
void ComputeUncentered()
Convenience method to center detector origin (use when inheriting)
Definition: CameraFocalPlaneMap.cpp:435
Isis::CameraFocalPlaneMap::p_detectorLine
double p_detectorLine
line value of the detector
Definition: CameraFocalPlaneMap.h:144
Isis::Camera
Definition: Camera.h:236
Isis::CameraFocalPlaneMap::DetectorSampleOrigin
double DetectorSampleOrigin() const
Definition: CameraFocalPlaneMap.cpp:310
Isis::CameraFocalPlaneMap::p_centeredDetectorSample
double p_centeredDetectorSample
Detector sample position.
Definition: CameraFocalPlaneMap.h:146
Isis::CameraFocalPlaneMap::DetectorSample
double DetectorSample() const
Definition: CameraFocalPlaneMap.cpp:255
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::CameraFocalPlaneMap::TransX
const double * TransX() const
Definition: CameraFocalPlaneMap.cpp:398
Isis::CameraFocalPlaneMap::CenteredDetectorLine
double CenteredDetectorLine() const
Definition: CameraFocalPlaneMap.cpp:279
Isis::CameraFocalPlaneMap::FocalPlaneXDependency
int FocalPlaneXDependency()
Return the focal plane x dependency variable.
Definition: CameraFocalPlaneMap.cpp:182
Isis::CameraFocalPlaneMap::p_detectorSample
double p_detectorSample
sample value of the detector
Definition: CameraFocalPlaneMap.h:145
Isis::CameraFocalPlaneMap::DetectorLineOffset
double DetectorLineOffset() const
Definition: CameraFocalPlaneMap.cpp:334
Isis::CameraFocalPlaneMap::p_detectorSampleOffset
double p_detectorSampleOffset
offset of the detector origin sample from the average
Definition: CameraFocalPlaneMap.h:150
Isis::CameraFocalPlaneMap::DetectorLineOrigin
double DetectorLineOrigin() const
Definition: CameraFocalPlaneMap.cpp:302
Isis::CameraFocalPlaneMap::TransL
const double * TransL() const
Definition: CameraFocalPlaneMap.cpp:422
Isis::CameraFocalPlaneMap::SetFocalPlane
virtual bool SetFocalPlane(const double dx, const double dy)
Compute detector position (sample,line) from focal plane coordinates.
Definition: CameraFocalPlaneMap.cpp:143
Isis::CameraFocalPlaneMap::Line
@ Line
The x value of the focal plane maps to a line.
Definition: CameraFocalPlaneMap.h:125
Isis::CameraFocalPlaneMap::p_centeredDetectorLine
double p_centeredDetectorLine
Detector line position.
Definition: CameraFocalPlaneMap.h:147
Isis::CameraFocalPlaneMap::p_transx
double p_transx[3]
The x transition from detector to distorted.
Definition: CameraFocalPlaneMap.h:152
Isis::CameraFocalPlaneMap::TransY
const double * TransY() const
Definition: CameraFocalPlaneMap.cpp:406
Isis::CameraFocalPlaneMap::SetTransY
void SetTransY(const QVector< double > transY)
Set the affine coefficients for converting detector (sample,line) to a distorted Y.
Definition: CameraFocalPlaneMap.cpp:388
Isis::CameraFocalPlaneMap::~CameraFocalPlaneMap
virtual ~CameraFocalPlaneMap()
Destructor.
Definition: CameraFocalPlaneMap.cpp:82
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::Camera::SetFocalPlaneMap
void SetFocalPlaneMap(CameraFocalPlaneMap *map)
Sets the Focal Plane Map.
Definition: Camera.cpp:2357
Isis::CameraFocalPlaneMap::CenteredDetectorSample
double CenteredDetectorSample() const
Definition: CameraFocalPlaneMap.cpp:271
Isis::CameraFocalPlaneMap::p_detectorSampleOrigin
double p_detectorSampleOrigin
The origin sample of the detector.
Definition: CameraFocalPlaneMap.h:140
Isis::CameraFocalPlaneMap::TransS
const double * TransS() const
Definition: CameraFocalPlaneMap.cpp:414
Isis::CameraFocalPlaneMap::Sample
@ Sample
The x value of the focal plane maps to a sample.
Definition: CameraFocalPlaneMap.h:124
Isis::CameraFocalPlaneMap::p_transy
double p_transy[3]
The y transition from detector to distorted.
Definition: CameraFocalPlaneMap.h:153
Isis::CameraFocalPlaneMap::FocalPlaneX
double FocalPlaneX() const
Definition: CameraFocalPlaneMap.cpp:239
Isis::CameraFocalPlaneMap::SetDetector
virtual bool SetDetector(const double sample, const double line)
Compute distorted focal plane coordinate from detector position (sampel,line)
Definition: CameraFocalPlaneMap.cpp:164
Isis::Affine
Affine basis function.
Definition: Affine.h:65
Isis::CameraFocalPlaneMap::SetTransL
void SetTransL(const QVector< double > transL)
Set the affine coefficients for converting destorted (x,y) to a detector Line.
Definition: CameraFocalPlaneMap.cpp:352
Isis::CameraFocalPlaneMap::SignMostSigY
double SignMostSigY()
Return the sign of the p_transy coefficient with the greatest magnitude.
Definition: CameraFocalPlaneMap.cpp:223
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::CameraFocalPlaneMap::p_focalPlaneX
double p_focalPlaneX
x value of focal plane coordinate
Definition: CameraFocalPlaneMap.h:142
QVector< double >
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
Isis::CameraFocalPlaneMap::p_itranss
double p_itranss[3]
The x transition from distorted to detector.
Definition: CameraFocalPlaneMap.h:154