# sqrt returns -1.IND / -1.INF -- mandelbrot fractal

This topic is 5228 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello guys! I try to make a mandelbrot picture. I am new to this stuff.. ( i am only 16! ) and havn't learnd it in school yet.. maybe my code is wrong. Thank you. sqrt((c1*c1) + (c2*c2)) returns -1.INF / -1.IND how? what do I wrong? :/ :) Here is my code:
    double c1 = 0, c2 = 0, c1_temp = 0;
int t = 0;
bool draw = false;

for( double x=-2; x<=1; x+=0.01)
{
for( double y=-1; y<= 1;y+=0.01 )
{
for( t = 0; t <= 400; t++)
{
c1_temp = c1;
c1 = ((c1*c1) - (c2*c2)) + x;
c2 =  (2*c1_temp*c2) + y;
draw = pixel_vector.testSqrt(c1, c2);
if(draw == false)
{
break;
}
}
if( draw == true )
{
// add pixel to the screen buffer
(
static_cast<int>( 100 * x )+200,
static_cast<int>( 100 * y )+100
, g_Blue, screen
);
}
}

}


bool CPixelVector::testSqrt( double c1, double c2 )
{
if( sqrt((c1*c1) + (c2*c2)) > 2 )
return false;
else
return true;
}


sqrt((c1*c1) + (c2*c2)) returns:
2.23607
3.17177
11.252
126.206
15929.4
2.53745e+008
6.43866e+016
4.14564e+033
1.71863e+067
2.95369e+134
1.#INF
1.#INF
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
-1.#IND
//...



##### Share on other sites
ok. I found the error! I forgot to reser c1 and c2 when I draw a pixel! works great now! :)

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633650
• Total Posts
3013119
×