Implémentation de RipplingMath.h
[GPU.git] / WCudaMSE / Student_OMP_Image / src / cpp / core / 01_Rippling / c_math / RipplingMath.h
index e57ccbe..4baf76e 100755 (executable)
@@ -1,7 +1,8 @@
 #ifndef RIPPLING_MATH_H_\r
 #define RIPPLING_MATH_H_\r
 \r
-#include <math>\r
+#include "MathTools.h"\r
+#include <cmath>\r
 using namespace std;\r
 \r
 /*----------------------------------------------------------------------*\\r
@@ -23,13 +24,12 @@ class RipplingMath
         \*-------------------------------------*/\r
 \r
     public:\r
-\r
-       RipplingMath(unsigned int w, unsigned int h))\r
+       RipplingMath(unsigned int w, unsigned int h)\r
+           : dim2 { w / 2.0 }\r
            {\r
-           this->dim2 = w / 2;\r
            }\r
 \r
-       virtual ~RipplingMath(void)\r
+       virtual ~RipplingMath()\r
            {\r
            //rien\r
            }\r
@@ -39,20 +39,23 @@ class RipplingMath
         \*-------------------------------------*/\r
 \r
     public:\r
-\r
        void colorIJ(uchar4* ptrColor, int i, int j, float t)\r
            {\r
-           // TODO\r
-           math::sin(9.1);\r
-asda\r
-           double a { 4 / 3 };\r
+           const double dxy10 = dxy(j, i) / 10.0;\r
+           const double grayLevelFloat = 128.0 + 127.0 * cos(dxy10 - t / 7.0) / (dxy10 + 1);\r
+           const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256);\r
+\r
+           ptrColor->x = grayLevel;\r
+           ptrColor->y = grayLevel;\r
+           ptrColor->z = grayLevel;\r
+\r
+           ptrColor->w = 255; // Opaque.\r
            }\r
 \r
     private:\r
-\r
-       void dxy(int i, int j, float* ptrResult) // par exmple\r
+       inline double dxy(int x, int y) // par exmple\r
            {\r
-           //TODO\r
+           return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0));\r
            }\r
 \r
     private:\r
@@ -62,10 +65,7 @@ asda
         \*-------------------------------------*/\r
 \r
     private:\r
-\r
-       // Tools\r
-       double dim2; //=dim/2\r
-\r
+       const double dim2; // = dim / 2.\r
     };\r
 \r
 #endif\r