 |
OpendTect
6.6
|
Go to the documentation of this file.
27 int n = (int) (val / period);
30 return n ? val - n * period : val;
38 template <
class T,
int P>
42 T
val(
bool positive=
true)
const
45 if ( !positive && res > ((T)
P)/2 )
72 { val_ = nv;
return this; }
74 { val_ += nv;
return this; }
76 { val_ -= nv;
return this; }
78 { val_ *= nv;
return this; }
80 { val_ /= nv;
return this; }
82 { val_ = nv.
val();
return this; }
84 { val_ += nv.
val();
return this; }
86 { val_ -= nv.
val();
return this; }
88 { val_ *= nv.
val();
return this; }
90 { val_ /= nv.
val();
return this; }
95 if ( tmp.
val(
true)>
P/2 )
return true;
101 if ( tmp.
val(
true)<=
P/2 )
return true;
105 {
return *this < PeriodicValue<T,P>(b); }
125 template <
class T,
class RT>
127 RT& ret,
RT period,
bool extrapolate=
false )
129 const float halfperiod = period / 2;
131 float dist = pos - intpos;
132 if(
mIsZero(dist,1e-10) && intpos >= 0 && intpos < sz )
133 { ret = idxabl[intpos];
return; }
135 int prevpos = dist > 0 ? intpos : intpos - 1;
136 if ( !extrapolate && (prevpos > sz-2 || prevpos < 0) )
138 else if ( prevpos < 1 )
140 const float val0 = idxabl[0];
142 while (
val1 - val0 > halfperiod )
val1 -= period;
143 while (
val1 - val0 < -halfperiod )
val1 += period;
148 else if ( prevpos > sz-3 )
150 const RT val0 = idxabl[sz-2];
152 while (
val1 - val0 > halfperiod )
val1 -= period;
153 while (
val1 - val0 < -halfperiod )
val1 += period;
159 const RT val0 = idxabl[prevpos-1];
161 RT val1 = idxabl[prevpos];
162 while (
val1 - val0 > halfperiod )
val1 -= period;
163 while (
val1 - val0 < -halfperiod )
val1 += period;
165 RT val2 = idxabl[prevpos+1];
169 RT val3 = idxabl[prevpos+2];
170 while ( val3 -
val2 > halfperiod ) val3 -= period;
171 while ( val3 -
val2 < -halfperiod ) val3 += period;
174 pos - prevpos ), period );
181 float period,
bool extrapolate=
false )
183 float ret =
mUdf(
float);
195 template <
class T,
class RT>
200 float dist = pos - intpos;
201 if(
mIsZero(dist,1e-10) && intpos >= 0 && intpos < sz )
202 { ret = idxabl[intpos];
return; }
204 int prevpos = dist > 0 ? intpos : intpos - 1;
205 const float relpos = pos - prevpos;
208 int prevpos2 = prevpos - 1;
211 int nextpos = prevpos + 1;
214 int nextpos2 = prevpos + 2;
217 const RT prevval2 = idxabl[prevpos2];
218 const RT prevval = idxabl[prevpos];
219 const RT nextval = idxabl[nextpos];
220 const RT nextval2 = idxabl[nextpos2];
Position-sorted indexable objects.
Definition: idxable.h:30
bool operator>(T b) const
Definition: periodicvalue.h:106
PeriodicValue< T, P > operator/(T nv) const
Definition: periodicvalue.h:60
const PeriodicValue< T, P > & operator+=(T nv)
Definition: periodicvalue.h:73
const T val1
Definition: arrayndalgo.h:1706
PeriodicValue< T, P > operator*(T nv) const
Definition: periodicvalue.h:58
const PeriodicValue< T, P > & operator/=(const PeriodicValue< T, P > &nv)
Definition: periodicvalue.h:89
bool operator<(const PeriodicValue< T, P > &b) const
Definition: periodicvalue.h:92
PeriodicValue< T, P > operator/(const PeriodicValue< T, P > &nv) const
Definition: periodicvalue.h:68
PeriodicValue< T, P > operator*(const PeriodicValue< T, P > &nv) const
Definition: periodicvalue.h:66
const PeriodicValue< T, P > & operator-=(const PeriodicValue< T, P > &nv)
Definition: periodicvalue.h:85
T val(bool positive=true) const
Definition: periodicvalue.h:42
void interpolateXPeriodicReg(const T &idxabl, int sz, float pos, RT &ret)
Definition: periodicvalue.h:196
const PeriodicValue< T, P > & operator*=(T nv)
Definition: periodicvalue.h:77
@ P
Definition: seistype.h:60
const PeriodicValue< T, P > & operator=(const PeriodicValue< T, P > &nv) const
Definition: periodicvalue.h:81
PeriodicValue< T, P > operator+(const PeriodicValue< T, P > &nv) const
Definition: periodicvalue.h:62
PeriodicValue< T, P > operator-(T nv) const
Definition: periodicvalue.h:56
void interpolateYPeriodicReg(const T &idxabl, int sz, float pos, RT &ret, RT period, bool extrapolate=false)
Definition: periodicvalue.h:126
#define mIsZero(x, eps)
Definition: commondefs.h:66
#define mClass(module)
Definition: commondefs.h:181
const PeriodicValue< T, P > & operator+=(const PeriodicValue< T, P > &nv)
Definition: periodicvalue.h:83
T val_
Definition: periodicvalue.h:113
const PeriodicValue< T, P > & operator=(T nv) const
Definition: periodicvalue.h:71
const PeriodicValue< T, P > & operator-=(T nv)
Definition: periodicvalue.h:75
PeriodicValue handles periodic data through mathematical operations.
Definition: periodicvalue.h:40
T dePeriodize(T val, T period)
Definition: periodicvalue.h:25
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
PeriodicValue< T, P > operator-(const PeriodicValue< T, P > &nv) const
Definition: periodicvalue.h:64
const T val2
Definition: arrayndalgo.h:1706
bool operator>(const PeriodicValue< T, P > &b) const
Definition: periodicvalue.h:98
T polyReg1D(T vm1, T v0, T v1, T v2, float x)
Definition: interpol1d.h:129
bool operator<(T b) const
Definition: periodicvalue.h:104
PeriodicValue< T, P > operator+(T nv) const
Definition: periodicvalue.h:54
const PeriodicValue< T, P > & operator/=(T nv)
Definition: periodicvalue.h:79
T linearReg1D(T v0, T v1, float x)
Definition: interpol1d.h:45
#define mNINT32(x)
Definition: commondefs.h:58
PeriodicValue(T nv)
Definition: periodicvalue.h:110
const PeriodicValue< T, P > & operator*=(const PeriodicValue< T, P > &nv)
Definition: periodicvalue.h:87
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021