Description
An unit rectangle has coordinates (0,0), (0,1), (1,0) and (1,1). A random number for x-axis and another random number for y-axis is generated in range 0 to 1. So they make a random coordinate.
Suppose the random coordinate is (M,N). So it subdivide the unit square into 4 sub-rectangles. Lets label them in a clockwise fashion like this picture- http://bit.ly/15TsSw6.
To determine the area of that sub-rectangles I used-
void area1(double a[],double ax[],double ay[])
{
ax[0]=M;
ay[0]=1-N;
a[0]= ax[0]*ay[0]; //area of first block
ax[1]=1-M;
ay[1]=ay[0];
a[1]=ax[1]*ay[1]; //area of second block
ax[2]=ax[1];
ay[2]=N;
a[2]=ax[2]*ay[2]; //area of third block
ax[3]=M;
ay[3]=N;
a[3]=ax[3]*ay[3]; //area of fourth block
cout<<endl;
}
Here's my problem:
Now let another set of coordinates are randomly generated. It will split one of those sub-rectangle another 4 blocks. This process will continue 100 times. And each time the randomly generated coordinates splits the rectangle near it into (3j+1) subrectangles (See the picture: http://bit.ly/11xyTOb).
How can I calculate the area of the sub-rectangles each time?[Edited]