Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image_Cuda / src / cpp / core / 02_Damier_Zoomable / moo / device / math / DamierMath.h
1 #ifndef DAMIER_MATH_H_
2 #define DAMIER_MATH_H_
3
4 #include <math.h>
5
6 #include "CalibreurF.h"
7 #include "ColorTools.h"
8
9
10 /*----------------------------------------------------------------------*\
11 |* Declaration *|
12 \*---------------------------------------------------------------------*/
13
14 /*--------------------------------------*\
15 |* Public *|
16 \*-------------------------------------*/
17
18
19 class DamierMath
20 {
21
22 /*--------------------------------------*\
23 |* Constructor *|
24 \*-------------------------------------*/
25
26 public:
27
28 __device__
29 DamierMath(int n):calibreur(IntervalF(-1, 1), IntervalF(0, 1))
30 {
31 this->n = n;
32 }
33
34 // constructeur copie automatique car pas pointeur dans
35 // DamierMath
36 // calibreur
37 // IntervalF
38
39 /*--------------------------------------*\
40 |* Methodes *|
41 \*-------------------------------------*/
42
43 public:
44
45 /**
46 * x=pixelI
47 * y=pixelJ
48 */
49 __device__
50 void colorXY(uchar4* ptrColor,float x, float y,float t)
51 {
52 float z = f(x, y,t);
53
54 calibreur.calibrer(z);
55 float hue01 = z;
56
57 ColorTools::HSB_TO_RVB(hue01,ptrColor); // update color
58
59 ptrColor->w = 255; // opaque
60 }
61
62 private:
63
64 __device__
65 float f(float x, float y,float t)
66 {
67 return sin(x * n + t) * cos(y * n + t);
68 }
69
70 /*--------------------------------------*\
71 |* Attributs *|
72 \*-------------------------------------*/
73
74 private:
75
76 // Input
77 int n;
78
79 // Tools
80 CalibreurF calibreur;
81
82 };
83
84
85
86 #endif
87
88
89
90 /*----------------------------------------------------------------------*\
91 |* End *|
92 \*---------------------------------------------------------------------*/