Commit 8cc3297c authored by Purves, Murray's avatar Purves, Murray
Browse files

Adding support for base values going high to low in radixmath::interpolateToNewBaseValues

parent ac74e198
......@@ -164,20 +164,38 @@ std::vector<T> interpolateToOtherBaseValues(
}
radix_line(" Initial interpolation complete");
// Work out if the base array goes low to high or high to low
bool lowToHigh = true;
if (baseValues.front() < baseValues.back())
{
radix_line(" Base values go low to high");
}
else
{
lowToHigh = false;
radix_line(" Base values go high to low");
}
// Iterate over the new base vector to calculate values at these positions
radix_line(" Interpolating to new base values");
for (size_t i = 0; i < newBaseValues.size(); ++i)
{
// Fill in values with a new base lower than the lowest original
if (newBaseValues[i] < baseValues.front())
if ((lowToHigh && newBaseValues[i] < baseValues.front()) ||
(!lowToHigh && newBaseValues[i] < baseValues.back()))
{
radix_line(" Base value below range: filling with lowest");
radix_line(" Base value "
<< newBaseValues[i] << " below range " << baseValues.front()
<< "-" << baseValues.back() << ": filling with lowest");
finalInterpolatedValues[i] = initialInterpolatedValues.front();
}
// Fill in values with a new base higher than the highest original
else if (newBaseValues[i] > baseValues.back())
else if ((lowToHigh && newBaseValues[i] > baseValues.back()) ||
(!lowToHigh && newBaseValues[i] > baseValues.front()))
{
radix_line(" Base value above range: filling with highest");
radix_line(" Base value "
<< newBaseValues[i] << " above range " << baseValues.front()
<< "-" << baseValues.back() << ": filling with highest");
finalInterpolatedValues[i] = initialInterpolatedValues.back();
}
// Fill in central values
......
......@@ -12,7 +12,7 @@
namespace radix
{
template <typename T>
extern std::vector<T> RADIX_PUBLIC interpolateValues(
std::vector<T> RADIX_PUBLIC interpolateValues(
const std::vector<T> &baseValues, const std::vector<T> &valuesToInterpolate,
const bool circular = false, const T missingValue = -9999.f);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment