I'm working on a numerical simulation program, for simplicity I recreated the code into expanding circles on a domain bounded on each side. I want to track each circle's radius. If I have this code:
int const N = 10;
int D[N+2][N+2]; //domain bounded on each side
int const nCircle = 4;
int center[nCircle][2] = {{1, 1}, {N, N}, {N, 1}, {1, N}};
void eval(); //function to expand circles
int main() {
for (int n=0;n<5;n++) {
eval();
for (int y=1;y<=N;y++) {
for (int x=1;x<=N;x++) {
printf("%d ", D[x][y]);
}
printf("\n");
}
printf("\n");
}
}
for visualization and simplicity purpose, add these into global definition
double radius[nCircle] = {2, 2, 2, 2}; //actually unknown, i want to track this
void eval() {
double a;
for (int z=0;z<nCircle;z++) {
for (int y=1;y<=N;y++) {
for (int x=1;x<=N;x++) {
a = pow(x-center[z][0], 2) + pow(y-center[z][1], 2);
if (a <= pow(radius[z], 2))
D[x][y] = 1;
}
}
radius[z] += ((double) rand() / (RAND_MAX));
}
}
How do I do that?
edit: note that circles might overlap each other, array D only store the union of circle area without information of the intersections.