Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Tuto_Image / src / cpp / core / 02_Damier_Zoomable / c_math / DamierMath.h
diff --git a/WCudaMSE/Tuto_Image/src/cpp/core/02_Damier_Zoomable/c_math/DamierMath.h b/WCudaMSE/Tuto_Image/src/cpp/core/02_Damier_Zoomable/c_math/DamierMath.h
new file mode 100755 (executable)
index 0000000..1b68e84
--- /dev/null
@@ -0,0 +1,85 @@
+#ifndef DAMIER_MATH_H_\r
+#define DAMIER_MATH_H_\r
+\r
+#include "CalibreurF.h"\r
+#include "ColorTools.h"\r
+#include <math.h>\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+/**\r
+ * Dans un header only pour preparer la version cuda\r
+ */\r
+class DamierMath\r
+    {\r
+       /*--------------------------------------*\\r
+        |*             Constructeur            *|\r
+        \*-------------------------------------*/\r
+\r
+    public:\r
+\r
+       /**\r
+        * calibreurColor : transformation affine entre [-1,1] (l'output de f(x,y)) et [0,1] (le spectre hsb)\r
+        */\r
+       DamierMath(int n) :\r
+               calibreur(IntervalF(-1, 1), IntervalF(0, 1))\r
+           {\r
+           this->n = n;\r
+           }\r
+\r
+       virtual ~DamierMath(void)\r
+           {\r
+           // rien\r
+           }\r
+\r
+       /*--------------------------------------*\\r
+       |*              Methode                 *|\r
+        \*-------------------------------------*/\r
+\r
+    public:\r
+\r
+       void colorXY(uchar4* ptrColor, double x, double y, const DomaineMath& domaineMath, double t)\r
+           {\r
+           float z = f(x, y, t);\r
+\r
+           calibreur.calibrer(z);\r
+           float hue01 = z;\r
+\r
+           ColorTools::HSB_TO_RVB(hue01, ptrColor); // update color\r
+\r
+           ptrColor->w = 255; // opaque\r
+           }\r
+\r
+    private:\r
+\r
+       double f(double x, double y, double t)\r
+           {\r
+           return sin(x * n + t) * cos(y * n + t); // t para animation\r
+           }\r
+\r
+       /*--------------------------------------*\\r
+       |*              Attribut                *|\r
+        \*-------------------------------------*/\r
+\r
+    protected:\r
+\r
+       // Inputs\r
+       int n;\r
+\r
+       // Tools\r
+       CalibreurF calibreur;\r
+\r
+    }\r
+;\r
+\r
+#endif \r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r