#ifndef RIPPLING_MATH_H_\r
#define RIPPLING_MATH_H_\r
\r
-#include <math.h>\r
+#include <cmath>\r
\r
/*----------------------------------------------------------------------*\\r
|* Declaration *|\r
\r
__device__\r
RipplingMath(int w, int h)\r
+ : dim2(w / 2.0)\r
{\r
- // TODO\r
- }\r
-\r
- __device__\r
- RipplingMath(const RipplingMath& source)\r
- {\r
- // TODO\r
}\r
\r
/*--------------------------------------*\\r
__device__\r
void color(int i, int j, float t, uchar4& color)\r
{\r
- // Debug (a mettre en commentaire)\r
- {\r
- unsigned char levelGris = 128; //in [0.255] (debug image)\r
- color.x = levelGris;\r
- color.y = levelGris;\r
- color.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
+ color.x = grayLevel;\r
+ color.y = grayLevel;\r
+ color.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
/*--------------------------------------*\\r
|* Attributs *|\r
\*-------------------------------------*/\r
\r
private:\r
+ const double dim2;\r
\r
// Tools\r
\r
};\r
\r
-#endif \r
+#endif\r
\r
/*----------------------------------------------------------------------*\\r
|* End *|\r