15 #include <tnt/tnt_array1d.h>
16 #include <tnt/tnt_array2d.h>
17 #include <tnt/tnt_array2d_utils.h>
21 #include "Constants.h"
22 #include "IException.h"
23 #include "PvlKeyword.h"
24 #include "SpecialPixel.h"
30 typedef TNT::Array1D<double> GVector;
56 Coordinate(
double y,
double x) : m_y(y), m_x(x) { }
62 void setLatLon(
const double &latitude,
const double &longitude) {
101 double yd = pntA.m_y - m_y;
102 double xd = pntA.m_x - m_x;
103 return (std::sqrt((xd * xd) + (yd * yd)));
111 inline double getLatitude()
const {
return (m_y); }
112 inline double getLongitude()
const {
return (m_x); }
113 inline double getLine()
const {
return (m_y); }
114 inline double getSample()
const {
return (m_x); }
132 return (
Coordinate(A.m_y+B.m_y, A.m_x+B.m_x));
150 return (
Coordinate(A.m_y-B.m_y, A.m_x-B.m_x));
174 PointPair(
const double &line,
const double &sample) : m_left(line, sample),
184 inline const Coordinate &getLeft()
const {
return (m_left); }
185 inline const Coordinate &getRight()
const {
return (m_right); }
187 inline double getLine()
const {
return (getLeftLine()); }
188 inline double getSample()
const {
return (getLeftSample()); }
189 inline double getLeftLine()
const {
return (m_left.getLine()); }
190 inline double getLeftSample()
const {
return (m_left.getSample()); }
191 inline double getRightLine()
const {
return (m_right.getLine()); }
192 inline double getRightSample()
const {
return (m_right.getSample()); }
209 Radiometric(
const double &shift,
const double &gain) :
210 m_shift(shift), m_gain(gain) { }
212 inline double Shift()
const {
return (m_shift); }
213 inline double Gain()
const {
return (m_gain); }
218 m_shift += B.m_shift;
229 return (
Radiometric(A.m_shift+B.m_shift, A.m_gain+B.m_gain));
245 AffineRadio(
const GMatrix &A) : m_affine(A), m_radio() { }
247 const double &gain) : m_affine(M), m_radio(shift, gain) { }
248 AffineRadio(
const GVector &alpha) : m_affine(), m_radio() {
258 m_radio += other.m_radio;
265 trans[0][2] = offset.getSample();
266 trans[1][2] = offset.getLine();
267 m_affine = TNT::matmult(trans, m_affine);
273 double x = m_affine[0][0] * location.getSample() +
274 m_affine[0][1] * location.getLine() + m_affine[0][2];
275 double y = m_affine[1][0] * location.getSample() +
276 m_affine[1][1] * location.getLine() + m_affine[1][2];
286 if ( alpha.dim1() != 8 ) {
287 QString mess =
"Alpha array for AffineRadio must have 8 elements "
288 " but has " +
toString(alpha.dim1());
292 m_affine[0][0] += alpha[1];
293 m_affine[0][1] += alpha[2];
294 m_affine[0][2] += alpha[0];
296 m_affine[1][0] += alpha[4];
297 m_affine[1][1] += alpha[5];
298 m_affine[1][2] += alpha[3];
300 m_radio.m_shift = alpha[6];
301 m_radio.m_gain = alpha[7];
321 AffineTolerance() : m_transTol(0.1), m_scaleTol(0.5), m_shearTol(0.5) { }
323 const double &shearTol) : m_transTol(transTol),
324 m_scaleTol(scaleTol),
325 m_shearTol(shearTol) { }
352 m_thresh[0] = tolerance.m_scaleTol / (((double)(chip.
Samples() - 1)) / 2.0);
353 m_thresh[1] = tolerance.m_shearTol / (((double)(chip.
Lines() - 1)) / 2.0);
354 m_thresh[2] = tolerance.m_transTol;
356 m_thresh[3] = tolerance.m_shearTol / (((double)(chip.
Samples() - 1)) / 2.0);
357 m_thresh[4] = tolerance.m_scaleTol / (((double)(chip.
Lines() - 1)) / 2.0);
358 m_thresh[5] = tolerance.m_transTol;
365 const double *alpha = Malpha[0];
366 for (
int i = 0 ; i < m_thresh.dim1() ; i++ ) {
367 if ( std::fabs(alpha[i]) >= m_thresh[i] )
return (
false);
384 Analysis() : m_npts(0), m_variance(0.0), m_sevals(),
385 m_kmat(), m_status(-1) {
386 for (
int i = 0 ; i < 2 ; i++ ) {
393 inline bool isValid()
const {
return (m_status == 0); }
397 double eigen = std::sqrt(m_sevals[0] * m_sevals[0] +
398 m_sevals[1] * m_sevals[1]);
404 for (
int i = 0 ; i < 2 ; i++ ) {
435 MatchPoint() : m_point(), m_affine(), m_analysis(), m_status(-1) { }
437 m_analysis(), m_status(-1) { }
439 m_analysis(), m_status(-1) { }
442 inline int getStatus()
const {
return (m_status); }
448 inline bool isValid()
const {
return (m_status == 0); }
449 inline double getEigen()
const {
return (m_analysis.
getEigen()); }