X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=WCudaMSE%2FStudent_OMP_Image%2Fsrc%2Fcpp%2Fcore%2F01_Rippling%2Fc_math%2FRipplingMath.h;h=4baf76efe73e0eb577fb36a1a1d98d48de805035;hb=00e3a81161ef7d45c0a4eb7f212cd6522afea394;hp=e57ccbecefa8cf65f4f40eb3287688290e6091b1;hpb=8d08c12b29c2a14684f35c023ee39e694bb80d25;p=GPU.git 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