isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Poly2d.h
1 //
2 // Author: Joshua Cohen
3 // Copyright 2017
4 //
5 
6 #pragma once
7 
8 #include "forward.h"
9 
10 #include <stdexcept>
11 #include <string>
12 #include <vector>
13 #include "Constants.h"
14 
26 public:
27 
33  double rangeMean;
35  double azimuthMean;
37  double rangeNorm;
39  double azimuthNorm;
41  std::vector<double> coeffs;
42 
51  Poly2d(int ro, int ao, double rm, double am, double rn, double an) : rangeOrder(ro),
52  azimuthOrder(ao),
53  rangeMean(rm),
54  azimuthMean(am),
55  rangeNorm(rn),
56  azimuthNorm(an),
57  coeffs((ro+1)*(ao+1))
58  {}
59 
61  Poly2d() : Poly2d(-1,-1,0.,0.,1.,1.) {}
62 
69  coeffs(p.coeffs) {}
70 
72  inline Poly2d& operator=(const Poly2d&);
73 
75  inline void setCoeff(int row, int col, double val);
76 
78  inline double getCoeff(int row, int col) const;
79 
81  double eval(double azi, double rng) const;
82 
84  void printPoly() const;
85 };
86 
88 operator=(const Poly2d &rhs) {
89  rangeOrder = rhs.rangeOrder;
91  rangeMean = rhs.rangeMean;
93  rangeNorm = rhs.rangeNorm;
95  coeffs = rhs.coeffs;
96  return *this;
97 }
98 
104 setCoeff(int row, int col, double val) {
105  if ((row < 0) || (row > azimuthOrder)) {
106  std::string errstr = "Poly2d::setCoeff - Trying to set coefficient for row " +
107  std::to_string(row+1) + " out of " +
108  std::to_string(azimuthOrder+1);
109  throw std::out_of_range(errstr);
110  }
111  if ((col < 0) || (col > rangeOrder)) {
112  std::string errstr = "Poly2d::setCoeff - Trying to set coefficient for col " +
113  std::to_string(col+1) + " out of " + std::to_string(rangeOrder+1);
114  throw std::out_of_range(errstr);
115  }
116  coeffs[IDX1D(row,col,rangeOrder+1)] = val;
117 }
118 
123 getCoeff(int row, int col) const {
124  if ((row < 0) || (row > azimuthOrder)) {
125  std::string errstr = "Poly2d::getCoeff - Trying to get coefficient for row " +
126  std::to_string(row+1) + " out of " +
127  std::to_string(azimuthOrder+1);
128  throw std::out_of_range(errstr);
129  }
130  if ((col < 0) || (col > rangeOrder)) {
131  std::string errstr = "Poly2d::getCoeff - Trying to get coefficient for col " +
132  std::to_string(col+1) + " out of " + std::to_string(rangeOrder+1);
133  throw std::out_of_range(errstr);
134  }
135  return coeffs[IDX1D(row,col,rangeOrder+1)];
136 }
Data structure for representing 1D polynomials.
Definition: Poly2d.h:25
Poly2d & operator=(const Poly2d &)
Assignment operator.
Definition: Poly2d.h:88
int rangeOrder
Order of polynomial in range or x.
Definition: Poly2d.h:29
int azimuthOrder
Order of polynomial in azimuth or y.
Definition: Poly2d.h:31
double getCoeff(int row, int col) const
Get coefficient by indices.
Definition: Poly2d.h:123
Poly2d()
Empty constructor.
Definition: Poly2d.h:61
double azimuthNorm
Norm in azimuth or y direction.
Definition: Poly2d.h:39
std::vector< double > coeffs
Linearized vector of coefficients in row-major format.
Definition: Poly2d.h:41
Poly2d(int ro, int ao, double rm, double am, double rn, double an)
Simple constructor.
Definition: Poly2d.h:51
double rangeNorm
Norm in range or x direction.
Definition: Poly2d.h:37
double azimuthMean
Mean in azimuth or y direction.
Definition: Poly2d.h:35
void printPoly() const
Printing for debugging.
Definition: Poly2d.cpp:32
void setCoeff(int row, int col, double val)
Set coefficient by indices.
Definition: Poly2d.h:104
Poly2d(const Poly2d &p)
Copy constructor.
Definition: Poly2d.h:66
double rangeMean
Mean in range or x direction.
Definition: Poly2d.h:33
double eval(double azi, double rng) const
Evaluate polynomial at given y,x.
Definition: Poly2d.cpp:14

Generated for ISCE3.0 by doxygen 1.8.5.