66 int DstSizeXm1 = a_DstSizeX - 1;
67 int SrcSizeXm1 = a_SrcSizeX - 1;
68 float fDstSizeXm1 =
static_cast<float>(DstSizeXm1);
69 float fSrcSizeXm1 =
static_cast<float>(SrcSizeXm1);
70 for (
int x = 1; x < DstSizeXm1; x++)
72 int SrcIdx = x * SrcSizeXm1 / DstSizeXm1;
73 float ValLo = a_Src[SrcIdx];
74 float ValHi = a_Src[SrcIdx + 1];
75 float Ratio =
static_cast<float>(x) * fSrcSizeXm1 / fDstSizeXm1 - SrcIdx;
76 a_Dst[x] = ValLo + (ValHi - ValLo) * Ratio;
78 a_Dst[a_DstSizeX - 1] = a_Src[a_SrcSizeX - 1];
88 int a_SrcSizeX,
int a_SrcSizeY,
90 int a_DstSizeX,
int a_DstSizeY
103 for (
int x = 1; x < a_DstSizeX; x++)
105 SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
106 RatioX[x] = (
static_cast<float>(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
108 for (
int y = 1; y < a_DstSizeY; y++)
110 SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
111 RatioY[y] = (
static_cast<float>(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
119 SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
120 RatioX[a_DstSizeX - 1] = 1;
121 SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
122 RatioY[a_DstSizeY - 1] = 1;
126 for (
int y = 0; y < a_DstSizeY; y++)
128 int idxLoY = a_SrcSizeX * SrcIdxY[y];
129 int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
130 float ry = RatioY[y];
131 for (
int x = 0; x < a_DstSizeX; x++)
134 float LoXLoY = a_Src[SrcIdxX[x] + idxLoY];
135 float HiXLoY = a_Src[SrcIdxX[x] + 1 + idxLoY];
136 float LoXHiY = a_Src[SrcIdxX[x] + idxHiY];
137 float HiXHiY = a_Src[SrcIdxX[x] + 1 + idxHiY];
140 float InterpXLoY = LoXLoY + (HiXLoY - LoXLoY) * RatioX[x];
141 float InterpXHiY = LoXHiY + (HiXHiY - LoXHiY) * RatioX[x];
144 a_Dst[idx] = InterpXLoY + (InterpXHiY - InterpXLoY) * ry;
156 int a_SrcSizeX,
int a_SrcSizeY,
int a_SrcSizeZ,
158 int a_DstSizeX,
int a_DstSizeY,
int a_DstSizeZ
175 for (
int x = 1; x < a_DstSizeX; x++)
177 SrcIdxX[x] = x * (a_SrcSizeX - 1) / (a_DstSizeX - 1);
178 RatioX[x] = (
static_cast<float>(x * (a_SrcSizeX - 1)) / (a_DstSizeX - 1)) - SrcIdxX[x];
180 for (
int y = 1; y < a_DstSizeY; y++)
182 SrcIdxY[y] = y * (a_SrcSizeY - 1) / (a_DstSizeY - 1);
183 RatioY[y] = (
static_cast<float>(y * (a_SrcSizeY - 1)) / (a_DstSizeY - 1)) - SrcIdxY[y];
185 for (
int z = 1; z < a_DstSizeZ; z++)
187 SrcIdxZ[z] = z * (a_SrcSizeZ - 1) / (a_DstSizeZ - 1);
188 RatioZ[z] = (
static_cast<float>(z * (a_SrcSizeZ - 1)) / (a_DstSizeZ - 1)) - SrcIdxZ[z];
198 SrcIdxX[a_DstSizeX - 1] = a_SrcSizeX - 2;
199 RatioX[a_DstSizeX - 1] = 1;
200 SrcIdxY[a_DstSizeY - 1] = a_SrcSizeY - 2;
201 RatioY[a_DstSizeY - 1] = 1;
202 SrcIdxZ[a_DstSizeZ - 1] = a_SrcSizeZ - 2;
203 RatioZ[a_DstSizeZ - 1] = 1;
207 for (
int z = 0; z < a_DstSizeZ; z++)
209 int idxLoZ = a_SrcSizeX * a_SrcSizeY * SrcIdxZ[z];
210 int idxHiZ = a_SrcSizeX * a_SrcSizeY * (SrcIdxZ[z] + 1);
211 float rz = RatioZ[z];
212 for (
int y = 0; y < a_DstSizeY; y++)
214 int idxLoY = a_SrcSizeX * SrcIdxY[y];
215 int idxHiY = a_SrcSizeX * (SrcIdxY[y] + 1);
216 float ry = RatioY[y];
217 for (
int x = 0; x < a_DstSizeX; x++)
220 float LoXLoYLoZ = a_Src[SrcIdxX[x] + idxLoY + idxLoZ];
221 float HiXLoYLoZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxLoZ];
222 float LoXHiYLoZ = a_Src[SrcIdxX[x] + idxHiY + idxLoZ];
223 float HiXHiYLoZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxLoZ];
224 float LoXLoYHiZ = a_Src[SrcIdxX[x] + idxLoY + idxHiZ];
225 float HiXLoYHiZ = a_Src[SrcIdxX[x] + 1 + idxLoY + idxHiZ];
226 float LoXHiYHiZ = a_Src[SrcIdxX[x] + idxHiY + idxHiZ];
227 float HiXHiYHiZ = a_Src[SrcIdxX[x] + 1 + idxHiY + idxHiZ];
230 float LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * rz;
231 float HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * rz;
232 float LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * rz;
233 float HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * rz;
236 float LoXInYInZ = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * ry;
237 float HiXInYInZ = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * ry;
240 a_Dst[idx] = LoXInYInZ + (HiXInYInZ - LoXInYInZ) * RatioX[x];
void LinearInterpolate2DArray(float *a_Src, int a_SrcSizeX, int a_SrcSizeY, float *a_Dst, int a_DstSizeX, int a_DstSizeY)
Puts linearly interpolated values from one array into another array.
void LinearInterpolate3DArray(float *a_Src, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, float *a_Dst, int a_DstSizeX, int a_DstSizeY, int a_DstSizeZ)
Puts linearly interpolated values from one array into another array.
void LinearInterpolate1DArray(float *a_Src, int a_SrcSizeX, float *a_Dst, int a_DstSizeX)
Puts linearly interpolated values from one array into another array.
const int MAX_INTERPOL_SIZEZ
Maximum Z-size of the interpolated array.
const int MAX_INTERPOL_SIZEY
Maximum Y-size of the interpolated array.
const int MAX_INTERPOL_SIZEX
Maximum X-size of the interpolated array.