summaryrefslogtreecommitdiffstats
path: root/src/LinearInterpolation.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/LinearInterpolation.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/LinearInterpolation.cpp b/src/LinearInterpolation.cpp
index 38404147f..f0465385d 100644
--- a/src/LinearInterpolation.cpp
+++ b/src/LinearInterpolation.cpp
@@ -23,8 +23,8 @@ public:
// DoTest1();
DoTest2();
}
-
-
+
+
void DoTest1(void)
{
float In[8] = {0, 1, 2, 3, 1, 2, 2, 2};
@@ -34,8 +34,8 @@ public:
LinearInterpolate3DArray(In, 2, 2, 2, Out, 3, 3, 3);
LOGD("Out[0]: %f", Out[0]);
}
-
-
+
+
void DoTest2(void)
{
float In[3 * 3 * 3];
@@ -94,7 +94,7 @@ void LinearInterpolate2DArray(
ASSERT(a_DstSizeX < MAX_INTERPOL_SIZEX);
ASSERT(a_DstSizeY > 0);
ASSERT(a_DstSizeY < MAX_INTERPOL_SIZEY);
-
+
// Calculate interpolation ratios and src indices along each axis:
float RatioX[MAX_INTERPOL_SIZEX];
float RatioY[MAX_INTERPOL_SIZEY];
@@ -110,7 +110,7 @@ void LinearInterpolate2DArray(
SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
RatioY[y] = (static_cast<float>(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
}
-
+
// Special values at the ends. Notice especially the last indices being (size - 2) with ratio set to 1, to avoid index overflow:
SrcIdxX[0] = 0;
RatioX[0] = 0;
@@ -120,7 +120,7 @@ void LinearInterpolate2DArray(
RatioX[a_DstSizeX - 1] = 1;
SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
RatioY[a_DstSizeY - 1] = 1;
-
+
// Output all the dst array values using the indices and ratios:
int idx = 0;
for (int y = 0; y < a_DstSizeY; y++)
@@ -135,11 +135,11 @@ void LinearInterpolate2DArray(
float HiXLoY = a_Src[SrcIdxX[x] + 1 + idxLoY];
float LoXHiY = a_Src[SrcIdxX[x] + idxHiY];
float HiXHiY = a_Src[SrcIdxX[x] + 1 + idxHiY];
-
+
// Linear interpolation along the X axis:
float InterpXLoY = LoXLoY + (HiXLoY - LoXLoY) * RatioX[x];
float InterpXHiY = LoXHiY + (HiXHiY - LoXHiY) * RatioX[x];
-
+
// Linear interpolation along the Y axis:
a_Dst[idx] = InterpXLoY + (InterpXHiY - InterpXLoY) * ry;
idx += 1;
@@ -235,7 +235,7 @@ void LinearInterpolate3DArray(
// Linear interpolation along the Y axis:
float LoXInYInZ = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * ry;
float HiXInYInZ = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * ry;
-
+
// Linear interpolation along the X axis:
a_Dst[idx] = LoXInYInZ + (HiXInYInZ - LoXInYInZ) * RatioX[x];
idx += 1;