Commencement du labo Mandelbrot et Julia.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 02_Mandelbrot_Julia / moo / device / math / FractalMath.h
diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/math/FractalMath.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/math/FractalMath.h
new file mode 100755 (executable)
index 0000000..2bd56ae
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef FRACTAL_MATH_H_\r
+#define FRACTAL_MATH_H_\r
+\r
+#include <cmath>\r
+\r
+#include "CalibreurF.h"\r
+#include "ColorTools.h"\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+class FractalMath\r
+    {\r
+\r
+       /*--------------------------------------*\\r
+       |*              Constructor             *|\r
+        \*-------------------------------------*/\r
+\r
+    public:\r
+\r
+       __device__\r
+       FractalMath(int n)\r
+           : n(n), calibreur(IntervalF(-1, 1), IntervalF(0, 1))\r
+           {\r
+           }\r
+\r
+       /*--------------------------------------*\\r
+       |*              Methodes                *|\r
+        \*-------------------------------------*/\r
+\r
+    public:\r
+       /**\r
+        * x=pixelI\r
+        * y=pixelJ\r
+        */\r
+       __device__\r
+       void colorXY(uchar4* ptrColor, float x, float y, float 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
+       __device__\r
+       float f(float x, float y,float t)\r
+           {\r
+           return sin(x * n + t) * cos(y * n + t);\r
+           }\r
+\r
+\r
+       /*--------------------------------------*\\r
+       |*              Attributs               *|\r
+        \*-------------------------------------*/\r
+\r
+    private:\r
+       // Input\r
+       int n;\r
+\r
+       // Tools\r
+       CalibreurF calibreur;\r
+    };\r
+\r
+#endif\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r