Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image / src / cpp / core / 02_Damier_Zoomable / c_math / DamierMath.h
1 #ifndef DAMIER_MATH_H_
2 #define DAMIER_MATH_H_
3
4 #include "CalibreurF.h"
5 #include "ColorTools.h"
6 #include <math.h>
7
8 /*----------------------------------------------------------------------*\
9 |* Declaration *|
10 \*---------------------------------------------------------------------*/
11
12 /*--------------------------------------*\
13 |* Public *|
14 \*-------------------------------------*/
15
16 /**
17 * Dans un header only pour preparer la version cuda
18 */
19 class DamierMath
20 {
21 /*--------------------------------------*\
22 |* Constructeur *|
23 \*-------------------------------------*/
24
25 public:
26
27 /**
28 * calibreurColor : transformation affine entre [-1,1] (l'output de f(x,y)) et [0,1] (le spectre hsb)
29 */
30 DamierMath(int n) :
31 calibreur(IntervalF(-1, 1), IntervalF(0, 1))
32 {
33 this->n = n;
34 }
35
36 virtual ~DamierMath(void)
37 {
38 // rien
39 }
40
41 /*--------------------------------------*\
42 |* Methode *|
43 \*-------------------------------------*/
44
45 public:
46
47 void colorXY(uchar4* ptrColor, double x, double y, const DomaineMath& domaineMath, double t)
48 {
49 float z = f(x, y, t);
50
51 calibreur.calibrer(z);
52 float hue01 = z;
53
54 ColorTools::HSB_TO_RVB(hue01, ptrColor); // update color
55
56 ptrColor->w = 255; // opaque
57 }
58
59 private:
60
61 double f(double x, double y, double t)
62 {
63 return sin(x * n + t) * cos(y * n + t); // t para animation
64 }
65
66 /*--------------------------------------*\
67 |* Attribut *|
68 \*-------------------------------------*/
69
70 protected:
71
72 // Inputs
73 int n;
74
75 // Tools
76 CalibreurF calibreur;
77
78 }
79 ;
80
81 #endif
82
83 /*----------------------------------------------------------------------*\
84 |* End *|
85 \*---------------------------------------------------------------------*/