OpendTect  6.3
terrain3x3.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Nov 2016
9 ________________________________________________________________________
10 
11 */
12 
13 #include "algomod.h"
14 
15 
38 template <class T>
40 {
41 public:
42  Terrain3x3(T dist,const T* zvals=0);
43  void set(const T*);
47 
48  T valueAt(T x,T y) const;
49  T slope() const;
50  T direction() const;
51  T profileCurvature() const;
52  T planformCurvature() const;
53 
54  const T d_, d2_;
55  T a0_, ax_, ay_, axy_, ax2_, ay2_, ax2y_, ay2x_, ax2y2_;
56 
57 };
58 
59 
60 template <class T>
61 inline Terrain3x3<T>::Terrain3x3( T dist, const T* v )
62  : d_(dist)
63  , d2_(dist*dist)
64 {
65  if ( v )
66  set( v );
67  else
68  a0_ = ax_ = ay_ = axy_ = ax2_ = ay2_ = ax2y_ = ay2x_ = ax2y2_ = ((T)0);
69 }
70 
71 
72 template <class T>
73 inline void Terrain3x3<T>::set( const T* v )
74 {
75  ax2y2_ = ( v[4] + (v[2]+v[8]+v[0]+v[6])/4
76  - (v[5]+v[1]+v[7]+v[3])/4 ) / (d2_*d2_);
77  ay2x_ = ( (v[2]+v[8]-v[0]-v[6])/4 + (v[3]-v[5])/2 ) / (d2_*d_);
78  ax2y_ = ( (v[8]+v[6]-v[2]-v[0])/4 + (v[1]-v[7])/2 ) / (d2_*d_);
79  ax2_ = ( (v[1]+v[7])/2 - v[4] ) / (d2_);
80  ay2_ = ( (v[5]+v[3])/2 - v[4] ) / (d2_);
81  axy_ = ( v[8]+v[0]-v[2]-v[6] ) / (4*d2_);
82  ax_ = ( v[7]-v[1] ) / (2*d_);
83  ay_ = ( v[5]-v[3] ) / (2*d_);
84  a0_ = v[4];
85 }
86 
87 
88 template <class T>
89 inline T Terrain3x3<T>::valueAt( T x, T y ) const
90 {
91  const T x2 = x * x;
92  const T y2 = y * y;
93  return a0_ + ax_*x + ay_*y + axy_*x*y
94  + ax2_*x2 + ay2_*y2
95  + ax2y_*x*y2 + ay2x_*y*x2
96  + ax2y2_*x2*y2;
97 }
98 
99 
100 template <class T>
101 inline T Terrain3x3<T>::slope() const
102 {
103  return Math::Sqrt( ax_*ax_ + ay_*ay_ );
104 }
105 
106 
107 template <class T>
108 inline T Terrain3x3<T>::direction() const
109 {
110  return Math::Atan2( -ay_, -ax_ );
111 }
112 
113 
114 template <class T>
116 {
117  const T ax2 = ax_ * ax_;
118  const T ay2 = ay_ * ay_;
119  const T divby = ax2 + ay2;
120  return divby == 0 ? mUdf(T)
121  : 2 * (ax2_*ax2 + ay2_*ay2 + axy_*ax_*ay_) / divby;
122 }
123 
124 
125 template <class T>
127 {
128  const T ax2 = ax_ * ax_;
129  const T ay2 = ay_ * ay_;
130  const T divby = ax2 + ay2;
131  return divby == 0 ? mUdf(T)
132  : 2 * (ax2_*ay2 + ay2_*ax2 - axy_*ax_*ay_) / divby;
133 }
T ax2y2_
Definition: terrain3x3.h:55
T ax2y_
Definition: terrain3x3.h:55
T a0_
Definition: terrain3x3.h:55
float Atan2(float y, float x)
T valueAt(T x, T y) const
Definition: terrain3x3.h:89
T ay2_
Definition: terrain3x3.h:55
T axy_
Definition: terrain3x3.h:55
T ay2x_
Definition: terrain3x3.h:55
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
Sets up a terrain polynomial for a 3x3 grid from 2D regularly sampled data.
Definition: terrain3x3.h:39
T direction() const
-pi < d < pi, or undef
Definition: terrain3x3.h:108
const T d_
Definition: terrain3x3.h:54
const T d2_
Definition: terrain3x3.h:54
T ay_
Definition: terrain3x3.h:55
T planformCurvature() const
curv perp to slope dir
Definition: terrain3x3.h:126
T ax_
Definition: terrain3x3.h:55
Terrain3x3(T dist, const T *zvals=0)
Definition: terrain3x3.h:61
T profileCurvature() const
curv in slope direction
Definition: terrain3x3.h:115
TrcKeyZSampling::Dir direction(TrcKeyZSampling::Dir slctype, int dimnr)
Definition: trckeyzsampling.h:129
#define mClass(module)
Definition: commondefs.h:161
float Sqrt(float)
void set(const T *)
Definition: terrain3x3.h:73
T slope() const
Definition: terrain3x3.h:101
T ax2_
Definition: terrain3x3.h:55

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017