| 194 | inline bool getInterpolatedValidValue(double ndc_x, double ndc_y, float& value) |

| 195 | { |

| 196 | unsigned int i,j; |

| 197 | double ir, jr; |

| 198 | computeIndices(ndc_x, ndc_y, i, j, ir, jr); |

| 199 | value = 0.0f; |

| 200 | double div = 0.0f; |

| 201 | float v,r; |

| 202 | |

| 203 | r = (1.0f-ir)*(1.0f-jr); |

| 204 | if (r>0.0 && getValidValue(i,j,v)) |

| 205 | { |

| 206 | value += v*r; |

| 207 | div += r; |

| 208 | } |

| 209 | |

| 210 | r = (ir)*(1.0f-jr); |

| 211 | if (r>0.0 && getValidValue(i+1,j,v)) |

| 212 | { |

| 213 | value += v*r; |

| 214 | div += r; |

| 215 | } |

| 216 | |

| 217 | r = (ir)*(jr); |

| 218 | if (r>0.0 && getValidValue(i+1,j+1,v)) |

| 219 | { |

| 220 | value += v*r; |

| 221 | div += r; |

| 222 | } |

| 223 | |

| 224 | r = (1.0f-ir)*(jr); |

| 225 | if (r>0.0 && getValidValue(i,j+1,v)) |

| 226 | { |

| 227 | value += v*r; |

| 228 | div += r; |

| 229 | } |

| 230 | |

| 231 | if (div != 0.0) |

| 232 | { |

| 233 | value /= div; |

| 234 | return true; |

| 235 | } |

| 236 | |

| 237 | value = 0.0; |

| 238 | return false; |

| 239 | } |

| 240 | |