From 00e3a81161ef7d45c0a4eb7f212cd6522afea394 Mon Sep 17 00:00:00 2001 From: gburri Date: Wed, 1 Oct 2014 22:09:41 +0200 Subject: [PATCH] =?utf8?q?Impl=C3=A9mentation=20de=20RipplingMath.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../core/omp/02_pi/07_pi_for_promotionTab.cpp | 3 +- .../core/01_Rippling/c_math/RipplingMath.h | 34 +++++++++---------- .../src/cpp/core/01_Vague/c_math/VagueMath.h | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp index 8240aa3..9fcaf87 100755 --- a/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp +++ b/WCudaMSE/Student_OMP/src/cpp/core/omp/02_pi/07_pi_for_promotionTab.cpp @@ -1,4 +1,5 @@ #include +#include #include "00_pi_tools.h" #include "MathTools.h" #include "OmpTools.h" @@ -55,7 +56,7 @@ double piOMPforPromotionTab(int n) const double DX = 1.0/(double)n; double sums[NB_THREAD]; - memset(sums, 0, sizeof(sums)); // TODO + memset(sums, 0, sizeof(sums)); #pragma omp parallel for private(xi) for (int i = 0; i < n; i++) diff --git a/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h b/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h index e57ccbe..4baf76e 100755 --- a/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h +++ b/WCudaMSE/Student_OMP_Image/src/cpp/core/01_Rippling/c_math/RipplingMath.h @@ -1,7 +1,8 @@ #ifndef RIPPLING_MATH_H_ #define RIPPLING_MATH_H_ -#include +#include "MathTools.h" +#include using namespace std; /*----------------------------------------------------------------------*\ @@ -23,13 +24,12 @@ class RipplingMath \*-------------------------------------*/ public: - - RipplingMath(unsigned int w, unsigned int h)) + RipplingMath(unsigned int w, unsigned int h) + : dim2 { w / 2.0 } { - this->dim2 = w / 2; } - virtual ~RipplingMath(void) + virtual ~RipplingMath() { //rien } @@ -39,20 +39,23 @@ class RipplingMath \*-------------------------------------*/ public: - void colorIJ(uchar4* ptrColor, int i, int j, float t) { - // TODO - math::sin(9.1); -asda - double a { 4 / 3 }; + const double dxy10 = dxy(j, i) / 10.0; + const double grayLevelFloat = 128.0 + 127.0 * cos(dxy10 - t / 7.0) / (dxy10 + 1); + const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256); + + ptrColor->x = grayLevel; + ptrColor->y = grayLevel; + ptrColor->z = grayLevel; + + ptrColor->w = 255; // Opaque. } private: - - void dxy(int i, int j, float* ptrResult) // par exmple + inline double dxy(int x, int y) // par exmple { - //TODO + return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0)); } private: @@ -62,10 +65,7 @@ asda \*-------------------------------------*/ private: - - // Tools - double dim2; //=dim/2 - + const double dim2; // = dim / 2. }; #endif diff --git a/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h b/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h index aabd5dd..f8a8888 100755 --- a/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h +++ b/WCudaMSE/Tuto_Image/src/cpp/core/01_Vague/c_math/VagueMath.h @@ -51,7 +51,7 @@ class VagueMath { unsigned char levelGris; - f(levelGris,i, j, t); // update levelGris + f(levelGris, i, j, t); // update levelGris ptrColorIJ->x = levelGris; ptrColorIJ->y = levelGris; -- 2.43.0