42 int const size =
static_cast<int>(pVdXdata->size());
46 if (dX >= pVdXdata->at(size - 2))
53 while (dX > pVdXdata->at(i + 1))
57 double const dXL = pVdXdata->at(i);
58 double dYL = pVdYdata->at(i);
59 double const dXR = pVdXdata->at(i + 1);
60 double dYR = pVdYdata->at(i + 1);
71 double const ddYdX = (dYR - dYL) / (dXR - dXL);
73 return (dYL + ddYdX * (dX - dXL));
82 unsigned int const nSize =
static_cast<unsigned int>(pVnXdata->size());
86 if (nX >= pVnXdata->at(nSize - 2))
93 while (nX > pVnXdata->at(i + 1))
97 int const nXL = pVnXdata->at(i);
98 int const nXR = pVnXdata->at(i + 1);
100 double dYL = pVdYdata->at(i);
101 double dYR = pVdYdata->at(i + 1);
112 double const ddYdX = (dYR - dYL) /
static_cast<double>(nXR - nXL);
114 return dYL + ddYdX *
static_cast<double>(nX - nXL);
144 int const nXSize =
static_cast<int>(pVdX->size());
145 int const nXNewSize =
static_cast<int>(pVdXNew->size());
152 vector<double> VdYNew(nXNewSize, 0.0);
154 for (
int i = 0; i < nXNewSize; ++i)
156 int const idx =
nFindIndex(pVdX, pVdXNew->at(i));
158 if (pVdX->at(idx) > pVdXNew->at(i))
162 dX = pVdX->at(idx) - pVdX->at(idx - 1);
163 dY = pVdY->at(idx) - pVdY->at(idx - 1);
168 dX = pVdX->at(idx + 1) - pVdX->at(idx);
169 dY = pVdY->at(idx + 1) - pVdY->at(idx);
175 if (idx < nXSize - 1)
177 dX = pVdX->at(idx + 1) - pVdX->at(idx);
178 dY = pVdY->at(idx + 1) - pVdY->at(idx);
183 dX = pVdX->at(idx) - pVdX->at(idx - 1);
184 dY = pVdY->at(idx) - pVdY->at(idx - 1);
192 double const dM = dY / dX;
193 double const dB = pVdY->at(idx) - pVdX->at(idx) * dM;
196 VdYNew[nXNewSize - 1 - i] = (pVdXNew->at(i) * dM) + dB;
vector< double > VdInterpolateCShoreProfileOutput(vector< double > const *, vector< double > const *, vector< double > const *)
Returns a linearly interpolated vector of doubles, to make CShore profile output compatible with CME....
int nFindIndex(vector< double > const *, double const)
This is used by VdInterpolateCShoreProfileOutput, it returns the index of the value in pVdX which is ...