USGS

Isis 3.0 Object Programmers' Reference

Home

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 
66  p_detectorSampleOrigin = 0.0;
67  p_detectorLineOrigin = 0.0;
68  p_detectorSampleOffset = 0.0;
69  p_detectorLineOffset = 0.0;
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) {
89  p_camera->SetFocalPlaneMap(this);
90  }
91  }
92 
93 
99  }
100 
101 
108  void CameraFocalPlaneMap::Init(Camera *parent, const int naifIkCode) {
109  p_detectorSampleOrigin = 0.0;
110  p_detectorLineOrigin = 0.0;
111  p_detectorSampleOffset = 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();
184  p_focalPlaneX = p_transx[0] + (p_transx[1] * p_centeredDetectorSample) + (p_transx[2] * p_centeredDetectorLine) ;
185  p_focalPlaneY = p_transy[0] + (p_transy[1] * p_centeredDetectorSample) + (p_transy[2] * p_centeredDetectorLine) ;
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 
254  return p_focalPlaneX;
255  }
256 
257 
260  return p_focalPlaneY;
261  }
262 
263 
266  return p_detectorSample;
267  }
268 
269 
272  return p_detectorLine;
273  }
274 
275 
278  return p_centeredDetectorSample;
279  }
280 
281 
284  return p_centeredDetectorLine;
285  }
286 
287 
297  void CameraFocalPlaneMap::SetDetectorOrigin(const double sample, const double line) {
298  p_detectorSampleOrigin = sample;
299  p_detectorLineOrigin = line;
300  }
301 
302 
305  return p_detectorLineOrigin;
306  }
307 
308 
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 
333  return p_detectorLineOffset;
334  }
335 
336 
339  return p_detectorSampleOffset;
340  }
341 
342 
345  for (int i=0; i<3; ++i) {
346  p_itransl[i] = transL[i];
347  }
348  }
349 
350 
353  for (int i=0; i<3; ++i) {
354  p_itranss[i] = transS[i];
355  }
356  }
357 
358 
361  for (int i=0; i<3; ++i) {
362  p_transx[i] = transX[i];
363  }
364  }
365 
366 
369  for (int i=0; i<3; ++i) {
370  p_transy[i] = transY[i];
371  }
372  }
373 
374 
376  const double *CameraFocalPlaneMap::TransX() const{
377  return p_transx;
378  }
379 
380 
382  const double *CameraFocalPlaneMap::TransY() const{
383  return p_transy;
384  }
385 
386 
388  const double *CameraFocalPlaneMap::TransS() const{
389  return p_itranss;
390  }
391 
392 
394  const double *CameraFocalPlaneMap::TransL() const{
395  return p_itransl;
396  }
397 
398 
401  p_centeredDetectorSample = p_detectorSample - p_detectorSampleOrigin;
402  p_centeredDetectorLine = p_detectorLine - p_detectorLineOrigin;
403  }
404 
405 
408  p_detectorSample = p_centeredDetectorSample + p_detectorSampleOrigin;
409  p_detectorLine = p_centeredDetectorLine + p_detectorLineOrigin;
410  }
411 
412 }
413