#include <omp.h>\r
+#include <cstring>\r
#include "00_pi_tools.h"\r
#include "MathTools.h"\r
#include "OmpTools.h"\r
const double DX = 1.0/(double)n;\r
\r
double sums[NB_THREAD];\r
- memset(sums, 0, sizeof(sums)); // TODO\r
+ memset(sums, 0, sizeof(sums));\r
\r
#pragma omp parallel for private(xi)\r
for (int i = 0; i < n; i++)\r
#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
\*-------------------------------------*/\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
\*-------------------------------------*/\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
\*-------------------------------------*/\r
\r
private:\r
-\r
- // Tools\r
- double dim2; //=dim/2\r
-\r
+ const double dim2; // = dim / 2.\r
};\r
\r
#endif\r
{\r
unsigned char levelGris;\r
\r
- f(levelGris,i, j, t); // update levelGris\r
+ f(levelGris, i, j, t); // update levelGris\r
\r
ptrColorIJ->x = levelGris;\r
ptrColorIJ->y = levelGris;\r