Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image_Cuda / src / cpp / core / 01_Vague_smart / moo / device / math / VagueMath.h
1 #ifndef VAGUE_MATH_H_
2 #define VAGUE_MATH_H_
3
4 #include "MathTools.h"
5
6 /*----------------------------------------------------------------------*\
7 |* Declaration *|
8 \*---------------------------------------------------------------------*/
9
10 /*--------------------------------------*\
11 |* Public *|
12 \*-------------------------------------*/
13
14 class VagueMath
15 {
16
17 /*--------------------------------------*\
18 |* Constructor *|
19 \*-------------------------------------*/
20
21 public:
22
23 __device__ VagueMath(int w, int h)
24 {
25 this->factor = 4 * PI / (float) w;
26 }
27
28 __device__ VagueMath(const VagueMath& source)
29 {
30 // rien
31 }
32
33 /*--------------------------------------*\
34 |* Methodes *|
35 \*-------------------------------------*/
36
37 public:
38
39 /**
40 * x=pixelI
41 * y=pixelJ
42 */
43 __device__
44 void colorIJ(uchar4* ptrColor, int i, int j, float t)
45 {
46 unsigned char levelGris;
47
48 f(levelGris, i, j, t); // update levelGris
49
50 ptrColor->x = levelGris;
51 ptrColor->y = levelGris;
52 ptrColor->z = levelGris;
53
54 ptrColor->w = 255; // opaque
55 }
56
57 private:
58
59 __device__
60 void f(unsigned char& levelGris, int i, int j, float t)
61 {
62 // Example1
63 //unsigned char levelGris= 255 * abs(sin(t)); // same color for all the image (Hello image)
64
65 // Example2
66 levelGris = 255 * fabs(sin(i * factor + t));
67 }
68
69 /*--------------------------------------*\
70 |* Attributs *|
71 \*-------------------------------------*/
72
73 private:
74
75 double factor;
76
77 };
78
79 #endif
80
81 /*----------------------------------------------------------------------*\
82 |* End *|
83 \*---------------------------------------------------------------------*/