isce3 0.25.0
Loading...
Searching...
No Matches
Poly2d.h
1#pragma once
2
3#include "forward.h"
4
5#include <stdexcept>
6#include <string>
7#include <vector>
8#include "Constants.h"
9
21public:
22
24 int xOrder;
26 int yOrder;
28 double xMean;
30 double yMean;
32 double xNorm;
34 double yNorm;
36 std::vector<double> coeffs;
37
46 Poly2d(int xo, int yo, double xm, double ym, double xn, double yn) : xOrder(xo),
47 yOrder(yo),
48 xMean(xm),
49 yMean(ym),
50 xNorm(xn),
51 yNorm(yn),
52 coeffs((xo+1)*(yo+1))
53 {}
54
56 Poly2d() : Poly2d(-1,-1,0.,0.,1.,1.) {}
57
61 Poly2d(const Poly2d &p) : xOrder(p.xOrder), yOrder(p.yOrder),
62 xMean(p.xMean), yMean(p.yMean),
63 xNorm(p.xNorm), yNorm(p.yNorm),
64 coeffs(p.coeffs) {}
65
67 inline Poly2d& operator=(const Poly2d&);
68
70 inline void setCoeff(int row, int col, double val);
71
73 inline double getCoeff(int row, int col) const;
74
76 double eval(double y, double x) const;
77
79 void printPoly() const;
80};
81
83operator=(const Poly2d &rhs) {
84 xOrder = rhs.xOrder;
85 yOrder = rhs.yOrder;
86 xMean = rhs.xMean;
87 yMean = rhs.yMean;
88 xNorm = rhs.xNorm;
89 yNorm = rhs.yNorm;
90 coeffs = rhs.coeffs;
91 return *this;
92}
93
99setCoeff(int row, int col, double val) {
100 if ((row < 0) || (row > yOrder)) {
101 std::string errstr = "Poly2d::setCoeff - Trying to set coefficient for row " +
102 std::to_string(row+1) + " out of " +
103 std::to_string(yOrder+1);
104 throw std::out_of_range(errstr);
105 }
106 if ((col < 0) || (col > xOrder)) {
107 std::string errstr = "Poly2d::setCoeff - Trying to set coefficient for col " +
108 std::to_string(col+1) + " out of " + std::to_string(xOrder+1);
109 throw std::out_of_range(errstr);
110 }
111 coeffs[IDX1D(row,col,xOrder+1)] = val;
112}
113
118getCoeff(int row, int col) const {
119 if ((row < 0) || (row > yOrder)) {
120 std::string errstr = "Poly2d::getCoeff - Trying to get coefficient for row " +
121 std::to_string(row+1) + " out of " +
122 std::to_string(yOrder+1);
123 throw std::out_of_range(errstr);
124 }
125 if ((col < 0) || (col > xOrder)) {
126 std::string errstr = "Poly2d::getCoeff - Trying to get coefficient for col " +
127 std::to_string(col+1) + " out of " + std::to_string(xOrder+1);
128 throw std::out_of_range(errstr);
129 }
130 return coeffs[IDX1D(row,col,xOrder+1)];
131}
Data structure for representing 2D polynomials.
Definition Poly2d.h:20
double getCoeff(int row, int col) const
Get coefficient by indices.
Definition Poly2d.h:118
int yOrder
Order of polynomial in azimuth or y.
Definition Poly2d.h:26
Poly2d(int xo, int yo, double xm, double ym, double xn, double yn)
Simple constructor.
Definition Poly2d.h:46
double yNorm
Norm in azimuth or y direction.
Definition Poly2d.h:34
void setCoeff(int row, int col, double val)
Set coefficient by indices.
Definition Poly2d.h:99
void printPoly() const
Printing for debugging.
Definition Poly2d.cpp:27
double yMean
Mean in azimuth or y direction.
Definition Poly2d.h:30
Poly2d()
Empty constructor.
Definition Poly2d.h:56
double xNorm
Norm in range or x direction.
Definition Poly2d.h:32
int xOrder
Order of polynomial in range or x.
Definition Poly2d.h:24
std::vector< double > coeffs
Linearized vector of coefficients in row-major format.
Definition Poly2d.h:36
Poly2d(const Poly2d &p)
Copy constructor.
Definition Poly2d.h:61
double eval(double y, double x) const
Evaluate polynomial at given y/azimuth/row ,x/range/col.
Definition Poly2d.cpp:9
Poly2d & operator=(const Poly2d &)
Assignment operator.
Definition Poly2d.h:83
double xMean
Mean in range or x direction.
Definition Poly2d.h:28

Generated for ISCE3.0 by doxygen 1.13.2.