#ifndef RIPPLING_0_MATH_H_\r
#define RIPPLING_0_MATH_H_\r
\r
-#include <math.h>\r
+#include <cmath>\r
#include "MathTools.h"\r
\r
/*----------------------------------------------------------------------*\\r
\r
__device__\r
Rippling0Math(int w, int h)\r
+ : dim2(w / 2.0)\r
{\r
- // TODO\r
- }\r
-\r
- __device__\r
- Rippling0Math(const Rippling0Math& source)\r
- {\r
- // TODO\r
}\r
\r
/*--------------------------------------*\\r
__device__\r
void color(int i, int j, float t, uchar4* ptrColor)\r
{\r
- // Debug (a mettre en commentaire)\r
- {\r
- unsigned char levelGris = 128; //in [0.255] (debug image)\r
- ptrColor->x = levelGris;\r
- ptrColor->y = levelGris;\r
- ptrColor->z = levelGris;\r
- }\r
-\r
- // Vrai problem\r
- {\r
- // TODO\r
- }\r
-\r
- //color.w = 255; // opaque\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
\r
private:\r
+ __device__\r
+ double dxy(int x, int y)\r
+ {\r
+ return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0));\r
+ }\r
\r
/*--------------------------------------*\\r
|* Attributs *|\r
\*-------------------------------------*/\r
\r
private:\r
+ const double dim2;\r
\r
};\r
\r
-#endif \r
+#endif\r
\r
/*----------------------------------------------------------------------*\\r
|* End *|\r