36double dGetInterpolatedValue(vector<double>
const* pVdXdata, vector<double>
const* pVdYdata,
double dX,
bool bExtrapolate)
38 int size =
static_cast<int>(pVdXdata->size());
42 if (dX >= pVdXdata->at(size - 2))
49 while (dX > pVdXdata->at(i + 1))
53 double dXL = pVdXdata->at(i);
54 double dYL = pVdYdata->at(i);
55 double dXR = pVdXdata->at(i + 1);
56 double dYR = pVdYdata->at(i + 1);
67 double ddYdX = (dYR - dYL) / (dXR - dXL);
69 return (dYL + ddYdX * (dX - dXL));
76double dGetInterpolatedValue(vector<int>
const* pVnXdata, vector<double>
const* pVdYdata,
int nX,
bool bExtrapolate )
78 unsigned int nSize =
static_cast<unsigned int>(pVnXdata->size());
82 if (nX >= pVnXdata->at(nSize - 2))
89 while (nX > pVnXdata->at(i + 1))
93 int nXL = pVnXdata->at(i);
94 int nXR = pVnXdata->at(i + 1);
96 double dYL = pVdYdata->at(i);
97 double dYR = pVdYdata->at(i + 1);
108 double ddYdX = (dYR - dYL) /
static_cast<double>(nXR - nXL);
110 return dYL + ddYdX *
static_cast<double>(nX - nXL);
140 int nXSize =
static_cast<int>(pVdX->size());
141 int nXNewSize =
static_cast<int>(pVdXNew->size());
148 vector<double> VdYNew(nXNewSize, 0.0);
150 for (
int i = 0; i < nXNewSize; ++i)
154 if (pVdX->at(idx) > pVdXNew->at(i))
158 dX = pVdX->at(idx) - pVdX->at(idx - 1);
159 dY = pVdY->at(idx) - pVdY->at(idx - 1);
164 dX = pVdX->at(idx + 1) - pVdX->at(idx);
165 dY = pVdY->at(idx + 1) - pVdY->at(idx);
171 if (idx < nXSize - 1)
173 dX = pVdX->at(idx + 1) - pVdX->at(idx);
174 dY = pVdY->at(idx + 1) - pVdY->at(idx);
179 dX = pVdX->at(idx) - pVdX->at(idx - 1);
180 dY = pVdY->at(idx) - pVdY->at(idx - 1);
189 double dB = pVdY->at(idx) - pVdX->at(idx) * dM;
192 VdYNew[nXNewSize - 1 - i] = (pVdXNew->at(i) * dM) + dB;
int nFindIndex(vector< double > const *pVdX, double const dValueIn)
This is used by VdInterpolateCShoreProfileOutput, it returns the index of the value in pVdX which is ...
vector< double > VdInterpolateCShoreProfileOutput(vector< double > const *pVdX, vector< double > const *pVdY, vector< double > const *pVdXNew)
Returns a linearly interpolated vector of doubles, to make CShore profile output compatible with CME....