X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fdevice%2Fmath%2FFractalMath.h;fp=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fdevice%2Fmath%2FFractalMath.h;h=2bd56ae764275626b4edb2bb05b1b3e88ffe53e6;hb=7798b7c27cf13aaeada22faae8648df8cb339f1b;hp=0000000000000000000000000000000000000000;hpb=3e601cb6c0cc2c5b3a9b30ebf3ad1102e53c0e0b;p=GPU.git diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/math/FractalMath.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/math/FractalMath.h new file mode 100755 index 0000000..2bd56ae --- /dev/null +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/device/math/FractalMath.h @@ -0,0 +1,78 @@ +#ifndef FRACTAL_MATH_H_ +#define FRACTAL_MATH_H_ + +#include + +#include "CalibreurF.h" +#include "ColorTools.h" + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +class FractalMath + { + + /*--------------------------------------*\ + |* Constructor *| + \*-------------------------------------*/ + + public: + + __device__ + FractalMath(int n) + : n(n), calibreur(IntervalF(-1, 1), IntervalF(0, 1)) + { + } + + /*--------------------------------------*\ + |* Methodes *| + \*-------------------------------------*/ + + public: + /** + * x=pixelI + * y=pixelJ + */ + __device__ + void colorXY(uchar4* ptrColor, float x, float y, float t) + { + float z = f(x, y, t); + + calibreur.calibrer(z); + float hue01 = z; + + ColorTools::HSB_TO_RVB(hue01, ptrColor); // update color + + ptrColor->w = 255; // opaque + } + + private: + __device__ + float f(float x, float y,float t) + { + return sin(x * n + t) * cos(y * n + t); + } + + + /*--------------------------------------*\ + |* Attributs *| + \*-------------------------------------*/ + + private: + // Input + int n; + + // Tools + CalibreurF calibreur; + }; + +#endif + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/