Ejemplo n.º 1
0
/**
 * Override
 */
Animable_I<uchar4>* RaytracingProvider::createAnimable(void)
    {
    //DomaineMath domaineMath = DomaineMath(-2.1, -1.3, 0.8, 1.3);
    DomaineMath domaineMath = DomaineMath(-1.3, -1.4, 1.3, 1.4);

    // Animation;
    float dt = 1;
    int n = 20;
    int nbSphere = 50;
    Sphere* tabSphere = new Sphere[nbSphere];
    // Dimension
    int dw = 16 * 80;
    int dh = 16 * 60;

    AleaTools aleaTools = AleaTools();
    float bord = 200;
    for(int i=0;i<nbSphere;i++)
    	{
    	//TODO random
    	float rayon = aleaTools.uniformeAB(20, dw/10);
    	float x = aleaTools.uniformeAB(bord, dh -bord);
    	float y = aleaTools.uniformeAB(bord, dw -bord);
    	float z = aleaTools.uniformeAB(10, 2* dw);
    	float hue = aleaTools.uniforme01();
    	tabSphere[i] = Sphere(x,y,z,rayon,hue);
    	}

    return new Raytracing(dw, dh, dt, n, domaineMath, tabSphere, nbSphere);
    }
Ejemplo n.º 2
0
static double monteCarloSequentielleCuda(int n)
    {
    long sommeInTot = 0;
    long sommeOutTot = 0;
    float a = -1.0;
    float b = 1.0;
    float m = 8.5;
    AleaTools alea;

    for (long i = 0; i < n; i++)
	{
	double randX = alea.uniformeAB(a, b);
	double randY = alea.uniformeAB(0.0, m);

	if (randY <= fHost(randX))
	    {
	    sommeInTot++;
	    }
	else
	    {
	    sommeOutTot++;
	    }
	}

    double numerateur = (b - a) * m * sommeInTot;
    double denominateur = n;
    return (numerateur / denominateur) / 2;
    }
Ejemplo n.º 3
0
unsigned int* initTabData(int n)
    {
    unsigned int* tabData = new unsigned int[n];
    AleaTools alea;

    for (int i = 0; i < n; i++)
	{
	tabData[i] = alea.uniformeAB(0, 255);
	}

    return tabData;
    }