Implémentation de RipplingMath.h
[GPU.git] / WCudaMSE / Tuto_Image / src / cpp / core / 01_Vague / c_math / VagueMath.h
1 #ifndef VAGUE_MATH_H_
2 #define VAGUE_MATH_H_
3
4 #include "cudaType.h"
5 #include "MathTools.h"
6
7 /*----------------------------------------------------------------------*\
8 |* Declaration *|
9 \*---------------------------------------------------------------------*/
10
11 /*--------------------------------------*\
12 |* Public *|
13 \*-------------------------------------*/
14
15 /**
16 * Dans un header only pour preparer la version cuda
17 */
18 class VagueMath
19 {
20
21 /*--------------------------------------*\
22 |* Constructeur *|
23 \*-------------------------------------*/
24
25 public:
26
27 VagueMath(unsigned int w, unsigned int h)
28 {
29 this->factor = 4 * PI / (float) w;
30 }
31
32 virtual ~VagueMath(void)
33 {
34 //rien
35 }
36
37 /*--------------------------------------*\
38 |* Methode *|
39 \*-------------------------------------*/
40
41 public:
42
43 /**
44 * i in [0,h[
45 * j in [0,w[
46 * code commun �
47 * entrelacementOMP
48 * forAutoOMP
49 */
50 void colorIJ(uchar4* ptrColorIJ, int i, int j, int t)
51 {
52 unsigned char levelGris;
53
54 f(levelGris, i, j, t); // update levelGris
55
56 ptrColorIJ->x = levelGris;
57 ptrColorIJ->y = levelGris;
58 ptrColorIJ->z = levelGris;
59
60 ptrColorIJ->w = 255; // opaque
61 }
62
63 private:
64
65 void f( unsigned char& levelGris,int i, int j, float t)
66 {
67 // example1
68 // levelGris = 255 * fabs(sin(t)); // same color for all the image (Hello image)
69
70 // Example2
71 levelGris = 255 * fabs(sin(i * factor + t));
72 }
73
74 /*--------------------------------------*\
75 |* Attribut *|
76 \*-------------------------------------*/
77
78 private:
79
80 // Inputs
81 float factor;
82
83 };
84
85 #endif
86
87 /*----------------------------------------------------------------------*\
88 |* End *|
89 /*----------------------------------------------------------------------*/