49 virtual void set(
const T*) = 0;
50 virtual T apply(
float x,
float y)
const = 0;
67 inline void set(
const T*);
68 inline void set(T v00,T v01,T v10,T v11);
69 inline T apply(
float x,
float y)
const;
78 inline T
linearReg2D( T v00, T v01, T v10, T v11,
float x,
float y )
95 inline void set(
const T*);
96 inline void set(T v00,T v01,T v10,T v11);
97 inline T apply(
float x,
float y)
const;
131 inline PolyReg2D(
const T*,
float xstretch=1);
133 T v0m1,T v00, T v01,T v02,
134 T v1m1,T v10, T v11,T v12,
135 T v20, T v21,
float xstretch=1);
137 inline void set(
const T*);
138 inline void set( T vm10,T vm11,
139 T v0m1,T v00, T v01, T v02,
140 T v1m1,T v10, T v11, T v12,
143 inline T apply(
float x,
float y)
const;
156 inline T
polyReg2D( T vm10, T vm11, T v0m1, T v00, T v01, T v02,
157 T v1m1, T v10, T v11, T v12, T v20, T v21,
float x,
float y,
160 return PolyReg2D<T>(vm10,vm11,v0m1,v00,v01,v02,v1m1,v10,v11,v12,v20,v21,xs)
181 T v1m1,T v10,T v11,T v12,T v20,T v21,
184 inline void set(
const T*);
185 inline void set( T vm10,T vm11,
186 T v0m1,T v00, T v01, T v02,
187 T v1m1,T v10, T v11, T v12,
190 inline T apply(
float x,
float y)
const;
194 inline void fillOuter2Inner(T,T,T,T,T,T,T,T,T&,T&,T&,T&);
195 inline void fillInner2Inner(T&,T&,T&,T&);
196 inline void fillInner2Outer(T,T,T,T,T&,T&,T&,T&,T&,T&,T&,T&);
218 T v1m1, T v10, T v11, T v12, T v20, T v21,
float x,
float y )
220 return PolyReg2DWithUdf<T>(vm10,vm11,v0m1,v00,v01,v02,v1m1,v10,v11,v12,v20,
226 template <
class T>
inline 230 template <
class T>
inline 233 set( v[0], v[1], v[2], v[3] );
237 template <
class T>
inline 240 set( v00, v01, v10, v11 );
244 template <
class T>
inline 247 set( v[0], v[1], v[2], v[3] );
251 template <
class T>
inline 257 a_[3] = v11 + v00 - v10 - v01;
261 template <
class T>
inline 264 return a_[0] + a_[1] * x + a_[2] * y + a_[3] * x * y;
270 template <
class T>
inline 274 template <
class T>
inline 277 set( v[0], v[1], v[2], v[3] );
281 template <
class T>
inline 284 set( v00, v01, v10, v11 );
288 template <
class T>
inline 291 set( v[0], v[1], v[2], v[3] );
295 #define mFillIfUdfFromSquare(nd,left,right,opp) \ 298 if ( u##left##_ && u##right##_ ) \ 301 v##nd = u##left##_ || u##right##_ ? \ 302 (u##right##_ ? v##left : v##right) \ 303 : (v##left + v##right) / 2; \ 306 template <
class T>
inline 313 haveudf_ = u00_ || u10_ || u01_ || u11_;
323 intp_.set( v00, v01, v10, v11 );
327 #define mRetUdfIfNearestUdf() \ 329 ( u00_ && x < 0.5 && y < 0.5 ) \ 330 || ( u10_ && x >= 0.5 && y < 0.5 ) \ 331 || ( u01_ && x < 0.5 && y >= 0.5 ) \ 332 || ( u11_ && x >= 0.5 && y >= 0.5 ) ) ) \ 337 template <
class T>
inline 342 return intp_.apply( x, y );
349 template <
class T>
inline 355 template <
class T>
inline 363 template <
class T>
inline 365 T v0m1, T v00, T v01, T v02,
366 T v1m1, T v10, T v11, T v12,
367 T v20, T v21,
float xs )
370 set( vm10, vm11, v0m1, v00, v01, v02, v1m1, v10, v11, v12, v20, v21 );
374 template <
class T>
inline 378 set( v[4], v[5], v[6], v[0], v[1], v[7], v[8], v[2], v[3],
379 v[9], v[10], v[11] );
381 set( v[0], v[1], v[0], v[0], v[1], v[1], v[2], v[2], v[3],
386 template <
class T>
inline 388 T v0m1, T v00, T v01, T v02,
389 T v1m1, T v10, T v11, T v12,
395 ix0_.set( v0m1, v00, v01, v02 );
ix1_.set( v1m1, v10, v11, v12 );
396 iy0_.set( vm10, v00, v10, v20 );
iy1_.set( vm11, v01, v11, v21 );
400 template <
class T>
inline 404 if ( x <= 0 )
return ix0_.apply( y );
405 else if ( y <= 0 )
return iy0_.apply( x );
406 else if ( x >= 1 )
return ix1_.apply( y );
407 else if ( y >= 1 )
return iy1_.apply( x );
411 const T vx0 =
ix0_.apply( y );
412 const T vx1 =
ix1_.apply( y );
417 const T vy0 =
iy0_.apply( x );
418 const T vy1 =
iy1_.apply( x );
422 const T estx =
polyReg1D( vxm1, vx0, vx1, vx2, x );
423 const T esty =
polyReg1D( vym1, vy0, vy1, vy2, y );
424 const float distfromedgex = x > 0.5 ? 1 - x : x;
425 const float distfromedgey = y > 0.5 ? 1 - y : y;
427 const float wty = distfromedgex *
xs_;
428 return (distfromedgey * estx + wty * esty) / (distfromedgey + wty);
435 template <
class T>
inline 442 template <
class T>
inline 450 template <
class T>
inline 452 T v1m1,T v10, T v11, T v12, T v20,T v21,
456 set( vm10, vm11, v0m1, v00, v01, v02, v1m1, v10, v11, v12, v20, v21 );
460 template <
class T>
inline 464 set( v[4], v[5], v[6], v[0], v[1], v[7], v[8], v[2], v[3],
465 v[9], v[10], v[11] );
467 set( v[0], v[1], v[0], v[0], v[1], v[1], v[2], v[2], v[3],
472 template <
class T>
inline 474 T v1m1, T v12, T v20, T v21,
475 T& v00, T& v01, T& v10, T& v11 )
477 #define mFillWithEither(nd,cand1,cand2) \ 480 if ( !u##cand1##_ ) v##nd = v##cand1; \ 481 else if ( !u##cand2##_ ) v##nd = v##cand2; \ 489 #undef mFillWithEither 493 template <
class T>
inline 510 template <
class T>
inline 512 T& vm10, T& vm11, T& v0m1, T& v02,
513 T& v1m1, T& v12, T& v20, T& v21 )
515 #define mFillIfUdf(nd,src) if ( mIsUdf(v##nd) ) v##nd= v##src; 528 template <
class T>
inline 530 T v0m1, T v00, T v01, T v02,
531 T v1m1, T v10, T v11, T v12,
554 v00, v01, v10, v11 );
558 vm10, vm11, v0m1, v02, v1m1, v12, v20, v21 );
561 intp_.set( vm10, vm11, v0m1, v00, v01, v02, v1m1, v10, v11, v12, v20, v21 );
564 template <
class T>
inline 569 return intp_.apply( x, y );
573 #undef mFillIfUdfFromSquare 574 #undef mRetUdfIfNearestUdf void fillOuter2Inner(T, T, T, T, T, T, T, T, T &, T &, T &, T &)
Definition: interpol2d.h:473
Definition: interpol1d.h:38
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
void fillInner2Inner(T &, T &, T &, T &)
Definition: interpol2d.h:494
T v0m1_
Definition: interpol2d.h:148
bool u01_
Definition: interpol2d.h:202
PolyReg1D< T > iy1_
Definition: interpol2d.h:147
PolyReg2DWithUdf(float xstretch=1)
Definition: interpol2d.h:436
void fillInner2Outer(T, T, T, T, T &, T &, T &, T &, T &, T &, T &, T &)
Definition: interpol2d.h:511
#define mFillWithEither(nd, cand1, cand2)
bool u20_
Definition: interpol2d.h:210
bool u0m1_
Definition: interpol2d.h:206
T apply(float x, float y) const
Definition: interpol2d.h:565
#define mFillIfUdf(nd, src)
bool um10_
Definition: interpol2d.h:204
Linear 2D interpolation.
Definition: interpol2d.h:59
#define mRetUdfIfNearestUdf()
Definition: interpol2d.h:327
T linearReg2D(T v00, T v01, T v10, T v11, float x, float y)
Definition: interpol2d.h:78
bool u10_
Definition: interpol2d.h:201
Definition: interpol1d.h:92
LinearReg2D()
Definition: interpol2d.h:227
bool u00_
Definition: interpol2d.h:200
T polyReg1D(T vm1, T v0, T v1, T v2, float x)
Definition: interpol1d.h:130
T v02_
Definition: interpol2d.h:148
bool u00_
Definition: interpol2d.h:103
void set(const T *)
Definition: interpol2d.h:461
T delxm1_
Definition: interpol2d.h:149
T linearReg2DWithUdf(T v00, T v01, T v10, T v11, float x, float y)
Definition: interpol2d.h:111
bool u12_
Definition: interpol2d.h:209
#define mFillIfUdfFromSquare(nd, left, right, opp)
Definition: interpol2d.h:295
PolyReg2D(float xstretch=1)
Definition: interpol2d.h:350
T delym1_
Definition: interpol2d.h:149
PolyReg1D< T > ix1_
Definition: interpol2d.h:147
bool um11_
Definition: interpol2d.h:205
void set(const T *)
Definition: interpol2d.h:375
bool haveudf_
Definition: interpol2d.h:199
T apply(float x, float y) const
Definition: interpol2d.h:338
virtual ~Applier2D()
Definition: interpol2d.h:48
void set(const T *)
Definition: interpol2d.h:245
T delx2_
Definition: interpol2d.h:149
void set(const T *)
Definition: interpol2d.h:289
bool u11_
Definition: interpol2d.h:106
T v20_
Definition: interpol2d.h:148
PolyReg2D< T > intp_
Definition: interpol2d.h:198
PolyReg1D< T > iy0_
Definition: interpol2d.h:147
T apply(float x, float y) const
Definition: interpol2d.h:262
bool u11_
Definition: interpol2d.h:203
T polyReg2D(T vm10, T vm11, T v0m1, T v00, T v01, T v02, T v1m1, T v10, T v11, T v12, T v20, T v21, float x, float y, float xs=1)
Definition: interpol2d.h:156
PolyReg1D< T > ix0_
Definition: interpol2d.h:147
bool u01_
Definition: interpol2d.h:105
Linear 2D interpolation with standard undef handling.
Definition: interpol2d.h:87
float xs_
Definition: interpol2d.h:150
bool u1m1_
Definition: interpol2d.h:208
Interpolate 2D regularly sampled, using a 2nd order surface.
Definition: interpol2d.h:126
bool haveudf_
Definition: interpol2d.h:102
bool u21_
Definition: interpol2d.h:211
specification for a 2D interpolator
Definition: interpol2d.h:45
T polyReg2DWithUdf(T vm10, T vm11, T v0m1, T v00, T v01, T v02, T v1m1, T v10, T v11, T v12, T v20, T v21, float x, float y)
Definition: interpol2d.h:217
bool u10_
Definition: interpol2d.h:104
#define mClass(module)
Definition: commondefs.h:164
T vm10_
Definition: interpol2d.h:148
T apply(float x, float y) const
Definition: interpol2d.h:401
T dely2_
Definition: interpol2d.h:149
PolyReg2D which smoothly handles undefined values.
Definition: interpol2d.h:174
LinearReg2D< T > intp_
Definition: interpol2d.h:101
bool u02_
Definition: interpol2d.h:207
LinearReg2DWithUdf()
Definition: interpol2d.h:271