Accuracy fix in 3d table lookup
This commit is contained in:
parent
d791cacae6
commit
e44b800a6c
12
table.ino
12
table.ino
|
@ -288,7 +288,7 @@ int get3DTableValue(struct table3D *fromTable, int Y, int X)
|
||||||
|
|
||||||
if (yMaxValue == yMinValue)
|
if (yMaxValue == yMinValue)
|
||||||
{ q = (float)(Y - yMinValue); }
|
{ q = (float)(Y - yMinValue); }
|
||||||
else { q = ((float)(Y - yMaxValue)) / (float)(yMinValue - yMaxValue); }
|
else { q = 1- (((float)(Y - yMaxValue)) / (float)(yMinValue - yMaxValue)); }
|
||||||
|
|
||||||
float m = (1.0-p) * (1.0-q);
|
float m = (1.0-p) * (1.0-q);
|
||||||
float n = p * (1-q);
|
float n = p * (1-q);
|
||||||
|
@ -314,13 +314,11 @@ int get3DTableValue(struct table3D *fromTable, int Y, int X)
|
||||||
{ q = ((long)(Y - yMinValue) << 8); }
|
{ q = ((long)(Y - yMinValue) << 8); }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q = ((long)(Y - yMaxValue) << 8) / (yMinValue - yMaxValue);
|
q = 256 - (((long)(Y - yMaxValue) << 8) / (yMinValue - yMaxValue));
|
||||||
}
|
}
|
||||||
|
int m = ((256-p) * (256-q)) >> 8;
|
||||||
int m = ((257-p) * (257-q)) >> 8;
|
int n = (p * (256-q)) >> 8;
|
||||||
int n = (p * (257-q)) >> 8;
|
int o = ((256-p) * q) >> 8;
|
||||||
int o = ((257-p) * q) >> 8;
|
|
||||||
int r = (p * q) >> 8;
|
int r = (p * q) >> 8;
|
||||||
|
|
||||||
return ( (A * m) + (B * n) + (C * o) + (D * r) ) >> 8;
|
return ( (A * m) + (B * n) + (C * o) + (D * r) ) >> 8;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue