コード例 #1
0
void RunMandelbrotDSGold1(uchar4 *dst, const int imageW, const int imageH, const int crunch, const double xOff, const double yOff, 
						  const double xJParam, const double yJParam, const double scale, const uchar4 colors, const int frame, 
						  const int animationFrame, const bool isJulia)
{
    for (int iy = 0; iy < imageH; iy++)
        for (int ix = 0; ix < imageW; ix++) {
		    // Get the current pixel color
 		    int pixel = imageW * iy + ix;
		    uchar4 pixelColor = dst[pixel];
		    int count = 0;
    		
		    // Search for pixels out of tolerance surrounding the current pixel
		    if (ix > 0)
			    count += CheckColors(pixelColor, dst[pixel - 1]);
		    if (ix + 1 < imageW)
			    count += CheckColors(pixelColor, dst[pixel + 1]);
		    if (iy > 0)
			    count += CheckColors(pixelColor, dst[pixel - imageW]);
		    if (iy + 1 < imageH)
			    count += CheckColors(pixelColor, dst[pixel + imageW]);
		    if (count) {
			    // Calculate the location
				const double xPos = (double)ix * scale + xOff;
				const double yPos = (double)iy * scale + yOff;
				dfloat dsx, dsy, djx, djy ;
				dsdeq(dsx, xPos);
				dsdeq(dsy, yPos);
				dsdeq(djx, xJParam) ;
				dsdeq(djy, yJParam);

			    // Calculate the Mandelbrot index for the current location
			    int m = CalcMandelbrotDS(dsx, dsy, djx, djy, crunch, isJulia);
                m = m > 0 ? crunch - m : 0;
    	        
			    // Convert the Madelbrot index into a color
			    uchar4 color;
			    if (m) {
				    m += animationFrame;
				    color.x = m * colors.x;
				    color.y = m * colors.y;
				    color.z = m * colors.z;
			    } else {
				    color.x = 0;
				    color.y = 0;
				    color.z = 0;
			    }
    			
			    // Output the pixel
			    int frame1 = frame + 1;
			    int frame2 = frame1 / 2;
			    dst[pixel].x = (pixelColor.x * frame + color.x + frame2) / frame1;
			    dst[pixel].y = (pixelColor.y * frame + color.y + frame2) / frame1;
			    dst[pixel].z = (pixelColor.z * frame + color.z + frame2) / frame1;
		    }
        }
} // RunMandelbrotDSGold1
コード例 #2
0
void RunMandelbrotDSGold0(uchar4 *dst, const int imageW, const int imageH, const int crunch, const double xOff, const double yOff, 
						  const double xJParam, const double yJParam, const double scale, const uchar4 colors, const int frame, 
						  const int animationFrame, const bool isJulia)
{
    for (int iy = 0; iy < imageH; iy++)
        for (int ix = 0; ix < imageW; ix++) {
		    // Calculate the location
		    const double xPos = (double)ix * scale + xOff;
		    const double yPos = (double)iy * scale + yOff;
    		dfloat dsx, dsy, djx, djy ;
            dsdeq(dsx, xPos);
            dsdeq(dsy, yPos);
            dsdeq(djx, xJParam) ;
            dsdeq(djy, yJParam);

            // Calculate the Mandelbrot index for the current location
            int m = CalcMandelbrotDS(dsx, dsy, djx, djy, crunch, isJulia);
            m = m > 0 ? crunch - m : 0;

            // Convert the Madelbrot index into a color
            uchar4 color;
            if (m) {
			    m += animationFrame;
			    color.x = m * colors.x;
			    color.y = m * colors.y;
			    color.z = m * colors.z;
		    } else {
			    color.x = 0;
			    color.y = 0;
			    color.z = 0;
		    }
    		
            // Output the pixel
 		    int pixel = imageW * iy + ix;
            if (frame == 0) {
			    color.w = 0;
			    dst[pixel] = color;
            } else {
			    int frame1 = frame + 1;
			    int frame2 = frame1 / 2;
			    dst[pixel].x = (dst[pixel].x * frame + color.x + frame2) / frame1;
			    dst[pixel].y = (dst[pixel].y * frame + color.y + frame2) / frame1;
			    dst[pixel].z = (dst[pixel].z * frame + color.z + frame2) / frame1;
            }
        }
} // RunMandelbrotDSGold0
コード例 #3
0
// The core Mandelbrot calculation function in double precision
inline int CalcMandelbrotDS(const dfloat xPos, const dfloat yPos, 
							const dfloat xJParam, const dfloat yJParam, const int crunch, const bool isJulia)
{
    dfloat x, y, xx, yy, sum;
    int i = crunch;

	dfloat xC, yC ;
	if(isJulia) {
		dseq(xC, xJParam) ;     // xC0 = xJParam ;
		dseq(yC, yJParam) ;     // yC0 = yJParam ;
		dseq(y, yPos);      // y = yPos;
		dseq(x, xPos);      // x = xPos;
		dsmul(yy, y, y);    // yy = y * y;
		dsmul(xx, x, x);	// xx = x * x;
		dsadd(sum, xx, yy); // sum = xx + yy;
	}
	else {
		dseq(xC, xPos) ;     // xC = xPos ;
		dseq(yC, yPos) ;     // yC = yPos ;
		dsdeq(y, 0.0) ;	// y = 0 ;
		dsdeq(x, 0.0) ;	// x = 0 ;
		dsdeq(yy, 0.0) ;   // yy = 0 ;
		dsdeq(xx, 0.0) ;   // xx = 0 ;
		dsdeq(sum, 0.0) ;   // sum = 0 ;
	}
    while (--i && (sum[0] < 4.0f)) {
        dsmul(y, x, y);     // y = x * y * 2.0f + yC ;
        dsadd(y, y, y);
        dsadd(y, y, yC);

        dssub(x, xx, yy);   //  x = xx - yy + xC ;
        dsadd(x, x, xC);

        dsmul(yy, y, y);    // yy = y * y;
        dsmul(xx, x, x);    // xx = x * x;
        dsadd(sum, xx, yy); // sum = xx + yy;
    }
    return i;
} // CalcMandelbrotDS
コード例 #4
0
 HALMD_GPU_ENABLED dsfloat(T a,
   typename boost::enable_if<boost::is_same<T, double> >::type* dummy = 0)
 {
     dsdeq(hi, lo, a);
 }