void drawCircle(){ //Changed name so it was not a main() function. This way it can be put in a header and be called on by a main() function.
int counter = 0.1, numx, numy;
float circ, sample;
//got rid of 'double pi' because PI is already defined as a global variable.
printf("How many circles do you need?\n");
scanf("%s", &counter); //Add ampersand (&) sign before counter.
//While must be lowercase w to get 'while.'
while(counter > 0){ //changed word 'zero' to the number '0.'
numx = rand() % 640 + 0;
numy = rand() % 480 + 0;//These two random functions allow the circles to be drawn all over the screen instead of in just one spot.
circ = twoPI(pi) * sampleNormal();
circle(numx, numy, sampleNormal());//the 'n' on normal had to be capitalized.
printf("Circumference of circle I last drew was, %f", circ);//Added a ';' after parenthesis to end the line. Capitalize 'n' on normal again and add '()' after sampleNormal.
counter++;//Got rid of space between 'counter' and '++.'
for(int i = 0; i < 999999; i++){} //Added this 4 loop so the animation function will count to 1 million, which will slow it down a lot to be easily seen.
}//while ends
}//main ends, Don't use return 0 when you have (int* argc, char** argv) in main.
double sampleNormal() {
double u = ((double) rand() / (RAND_MAX)) * 2 - 1;
double v = ((double) rand() / (RAND_MAX)) * 2 - 1;
double r = (u * u) + (v * v);
double c = sqrt(-2 * log(r) / r); //Moved 'c' declaration up to other declared variables.
if (r == 0 || r > 1)
return sampleNormal();
else //Added an else statement
return u * c;
}//sampleNormal ends
double twoPI(double x){return pow(x, 2);}//twoPI ends
//I added an argument to twoPI so it could take a number. Changed pi's to the variable 'x' so PI could be called by twoPI in main() function.
What this does is creates unphysically correct ripples. Lol instead of ripples going outward like they would in water it just makes the ripples appear randomly any old place. But this is ok. My issue is making the circles being drawn disappear after 20 repetitions of the code. I did get the program to clear the circles as soon as they came up, which means all you could see were quick flashes of white
I don't think you can actually run this code since it requires a special program to be downloaded... But could anyone help with steering me towards ideas that SHOULD work?

New Topic/Question
Reply



MultiQuote





|