\*-------------------------------------*/\r
\r
ImageFonctionel::ImageFonctionel(AnimableFonctionel_I* ptrAnimable, ColorRGB_01* ptrColorTitreRGB) :\r
- ImageFonctionelMOOs_A(ptrAnimable->getW(), ptrAnimable->getH(), *ptrAnimable->getDomaineMathInit())\r
+ ImageFonctionelMOOs_A(\r
+ ptrAnimable->getW(),\r
+ ptrAnimable->getH(),\r
+ *ptrAnimable->getDomaineMathInit()\r
+ )\r
{\r
this->ptrAnimable = ptrAnimable;\r
this->ptrColorTitreRGB = ptrColorTitreRGB;\r
+ this->tName = ptrAnimable->getTName();\r
\r
setEnableDomaineOverlay(true);\r
}\r
// top\r
{\r
float t = ptrAnimable->getT();\r
- string message = "t = " + StringTools::toString(t);\r
+ string message = this->tName + StringTools::toString(t);\r
graphic2D.drawTitleTop(message, ptrfont);\r
}\r
\r
* getParaAnimation\r
*/\r
virtual float getT(void)=0;\r
+ virtual string getTName() { return "t = "; }\r
\r
virtual string getTitle(void)=0;\r
-\r
};\r
\r
#endif\r
// Input\r
AnimableFonctionel_I* ptrAnimable;\r
ColorRGB_01* ptrColorTitreRGB;\r
+\r
+ string tName;\r
};\r
\r
#endif\r
#include <stdio.h>\r
using namespace std;\r
\r
-#include "NewtonDevice.h"\r
-\r
#include "Indice2D.h"\r
#include "IndiceTools.h"\r
#include "cudaTools.h"\r
#include "Device.h"\r
\r
+#include "NewtonDevice.h"\r
#include "NewtonMath.h"\r
\r
__global__\r
C // (-1/2 -sqrt(3)/2)\r
};\r
\r
+ // Les trois solutions du système d'équation : A, B et C (vecteur 2D).\r
+ static const float A1 = 1.0;\r
+ static const float A2 = 0.0;\r
+ static const float B1 = -0.5; // -1.0 / 2.0\r
+ static const float B2 = 0.866025403785; // sqrt(3.0) / 2.0\r
+ static const float C1 = -0.5; // -1.0 / 2.0\r
+ static const float C2 = -0.866025403785; // -sqrt(3.0) / 2.0\r
+\r
public:\r
/*\r
* n est le nombre d'iteration.\r
__device__\r
void colorXY(uchar4* ptrColor, float x1, float x2) const\r
{\r
- const float A1 = 1.0;\r
- const float A2 = 0.0;\r
- const float B1 = -1.0 / 2.0;\r
- const float B2 = sqrt(3.0) / 2.0;\r
- const float C1 = -1.0 / 2.0;\r
- const float C2 = -sqrt(3.0) / 2.0;\r
-\r
- //const float epsilon = 0.1;\r
-\r
float nearest_current_solution_distance = FLT_MAX;\r
Solution nearest_current_solution = A;\r
\r
nearest_current_solution_distance = distance_to_C;\r
}\r
\r
- /*if (Indice2D::tid() == 0)\r
+ /* For DEBUG.\r
+ * if (Indice2D::tid() == 0)\r
{\r
printf("nearest_current_solution_distance: %f\n", nearest_current_solution_distance);\r
}*/\r
printf("d to a: %f\n", distance_to_A);\r
printf("d to a: %f\n", distance_to_B);\r
printf("d to a: %f\n", distance_to_C);\r
- }*/\r
+ }\r
+ */\r
\r
if (nearest_current_solution_distance < this->epsilon)\r
break;\r
__device__\r
static void nextX(float x1, float x2, float& x1_next, float& x2_next)\r
{\r
- float f_x1 = x1 * x1 * x2 - 3.0 * x1 * x2 * x2 - 1.0;\r
+ float f_x1 = x1 * x1 * x1 - 3.0 * x1 * x2 * x2 - 1.0;\r
float f_x2 = x2 * x2 * x2 - 3.0 * x1 * x1 * x2;\r
\r
// La matrice est représentée comme cela :\r
#include "Device.h"\r
#include "NewtonDevice.h"\r
\r
-Newton::Newton(int w, int h)\r
- : variateurN(IntervalI(5, 1000), 1),\r
- variateurEpsilon(IntervalF(0.01, 10), 0.01),\r
- w(w), h(h),\r
- dg(8, 8, 1),\r
- db(32, 32, 1),\r
- ptrDomaineMathInit(new DomaineMath(-2, -2, 2, 2)),\r
- title("Fractal Newton")\r
+Newton::Newton(int w, int h) :\r
+ variateurEpsilon(IntervalF(0.01, 1), 0.001),\r
+ w(w),\r
+ h(h),\r
+ dg(8, 8, 1),\r
+ db(32, 32, 1),\r
+ ptrDomaineMathInit(new DomaineMath(-2, -2, 2, 2)),\r
+ title("Fractal Newton")\r
{\r
Device::assertDim(dg, db);\r
}\r
\r
void Newton::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)\r
{\r
- newton<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->t, this->epsilon);\r
+ newton<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, 100, this->epsilon);\r
\r
HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).\r
}\r
\r
void Newton::animationStep()\r
{\r
- this->t = this->variateurN.varierAndGet();\r
this->epsilon = this->variateurEpsilon.varierAndGet();\r
}\r
\r
\r
float Newton::getT()\r
{\r
- return this->t;\r
+ return this->epsilon;\r
+ }\r
+\r
+string Newton::getTName()\r
+ {\r
+ return "epsilon : ";\r
}\r
\r
string Newton::getTitle()\r
DomaineMath* getDomaineMathInit() /*override*/;\r
\r
float getT() /*override*/;\r
+ string getTName();\r
\r
string getTitle(void) /*override*/;\r
\r
private:\r
- VariateurI variateurN; // Variateur sur le nombre d'iteration max.\r
VariateurF variateurEpsilon; // Variateur sur epsilon.\r
\r
- float t;\r
float epsilon;\r
\r
// Inputs\r
-#ifndef NEWTON_PROVIDER_H_\r
-#define NEWTON_PROVIDER_H_\r
+#ifndef NEWTON_PROVIDER_H\r
+#define NEWTON_PROVIDER_H\r
\r
#include "Newton.h"\r
#include "ImageFonctionel.h"\r
#include "Device.h"
#include "RayTracingDevice.h"
-#include "RayTracingMath.h"
__global__
-void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t)
+void rayTracing(uchar4* ptrDevPixels, int w, int h, float t)
{
const int TID = Indice2D::tid();
const int NB_THREAD = Indice2D::nbThread();
const int WH = w * h;
- RayTracingMath rayTracing; // TODO: prendre
-
uchar4 color;
color.w = 255; // Par défaut, l'image est opaque.
#include "DomaineMath.h"
__global__
-void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t);
+void rayTracing(uchar4* ptrDevPixels, int w, int h, float t);
#endif
#include "cudaTools.h"
#include "cudaType_CPU.h"
-#include "mathTools.h"
+#include "MathTools.h"
-#endif
class Sphere
{
public:
__host__
- Sphere(float3 centre, float r, float hue) :
+ Sphere(cpu::float3 centre, float r, float hue) :
centre(centre),
hueInitial(hue)
{
}
__host__
- void setCentre(float3 centre)
+ void setCentre(const cpu::float3& centre)
{
this->centre = centre;
}
}
__device__
- float hCarre(float2 xySol)
+ float hCarre(cpu::float2 xySol)
{
float a = (centre.x - xySol.x);
float b = (centre.y - xySol.y);
private:
float r;
- float3 centre;
+ cpu::float3 centre;
float hueInitial;
float rCarre;
+++ /dev/null
-#ifndef RAY_TRACING_MATH_H
-#define RAY_TRACING_MATH_H
-
-class RayTracingMath
- {
-
- };
-
-#endif
#include "RayTracing.h"
#include "Device.h"
#include "RayTracingDevice.h"
+#include "Sphere.h"
RayTracing::RayTracing(int w, int h)
: w(w), h(h),
Device::assertDim(dg, db);
const int nbSpheres = 10;
- Sphere* = this->createSpheres(10);
-
+ Sphere* shperes = this->createSpheres(10);
// Copie les spheres dans la constant memory.
}
RayTracing::~RayTracing()
{
- delete this->ptrDomaineMathInit;
}
-void RayTracing::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)
+void RayTracing::runGPU(uchar4* ptrDevPixels)
{
- rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->t);
+ rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, this->t);
HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
}
return this->title;
}
-Sphere* createSpheres(int n)
+Sphere* RayTracing::createSpheres(int n)
{
Sphere* spheres = new Sphere[n];
const float bord = 200;
for (int i = 0; i < n; ++i)
{
- spheres[i].setR(float(AleaTools::uniformeAB(20, this->w / 10 - 1)));
- spheres[i].setCentre(float3 {
- float(AleaTools::uniformeAB(bord, this->w - bord)),
- float(AleaTools::uniformeAB(bord, this->h - bord)),
- float(AleaTools::uniformeAB(10, 2.0 * this->w))
- });
- spheres[i].setHue(float(AleaTools::uniformeAB(0, 1))
+ spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1)));
+
+ cpu::float3 centre
+ {
+ float(this->alea.uniformeAB(double(bord), double(this->w - bord))),
+ float(this->alea.uniformeAB(double(bord), double(this->h - bord))),
+ float(this->alea.uniformeAB(10.0, 2.0 * this->w))
+ };
+
+ spheres[i].setCentre(centre);
+ spheres[i].setHueInitial(float(this->alea.uniformeAB(0.0, 1.0)));
}
}
#include "cudaTools.h"
#include "Animable_I.h"
#include "MathTools.h"
+#include "cudaType_CPU.h"
+
#include "Sphere.h"
class RayTracing : public Animable_I
private:
Sphere* createSpheres(int n);
+ AleaTools alea;
+
float t;
const int w;
return new RayTracing(dw, dh);
}
-ImageFonctionel* RayTracingProvider::createGL()
+Image* RayTracingProvider::createGL()
{
ColorRGB_01* ptrColorTitre = new ColorRGB_01(0, 0, 0);
- return new ImageFonctionel(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel
+ return new Image(create(), ptrColorTitre); // both ptr destroy by destructor of ImageFonctionel
}
#define RAYTRACING_PROVIDER_H
#include "RayTracing.h"
-#include "ImageFonctionel.h"
+#include "Image.h"
class RayTracingProvider
{
public:
static RayTracing* create();
- static ImageFonctionel* createGL();
+ static Image* createGL();
};
#endif
static const int NB_ITERATION_AVEUGLE = 1000;\r
\r
public:\r
- HeatTransfert();\r
+ HeatTransfert(int w, int h);\r
virtual ~HeatTransfert();\r
\r
void runGPU(uchar4* ptrDevPixels) /*override*/;\r
#include "FractalProvider.h"\r
#include "NewtonProvider.h"\r
#include "HeatTransfertProvider.h"\r
+#include "RayTracingProvider.h"\r
\r
template <class TOutput, class TProvider>\r
class Viewer\r
\r
int mainGL(void)\r
{\r
- //Viewer<Rippling0Image, Rippling0Provider> rippling0(true, true, 10, 10);\r
- //Viewer<Image, RipplingProvider> rippling0(true, true, 10, 10);\r
- //Viewer<ImageFonctionel, MandelbrotProvider> fractalMandelbrot(true, true, 20, 20);\r
- //Viewer<ImageFonctionel, JuliaProvider> fractalJulia(true, true, 30, 30);\r
+ // Viewer<Rippling0Image, Rippling0Provider> rippling0(true, true, 10, 10);\r
+ // Viewer<Image, RipplingProvider> rippling0(true, true, 10, 10);\r
+ // Viewer<ImageFonctionel, MandelbrotProvider> fractalMandelbrot(true, true, 20, 20);\r
+ // Viewer<ImageFonctionel, JuliaProvider> fractalJulia(true, true, 30, 30);\r
Viewer<ImageFonctionel, NewtonProvider> newtown(true, true, 20, 20);\r
- //Viewer<Image, HeatTransfertProvider> heatTransfert(true, false, 20, 20);\r
+ // Viewer<Image, HeatTransfertProvider> heatTransfert(true, false, 20, 20);\r
+ // Viewer<ImageFonctionel, RayTracingProvider> rayTracing(true, true, 20, 20);\r
\r
GLUTImageViewers::runALL(); // Bloquant, Tant qu'une fenetre est ouverte\r
\r