Circular zones - instructions for solving the task
Area: binary search, sorting array
You need 3 array:
Furthermore, using a binary search algorithm, look for a position in a series of radius, where the distance R from the center to the current point M (x, y)
located in a belt that precedes the radius in a row at the examined position.
For example, if the distance from the center of the center R is calculated from the radius in a row at the current position with r [s], then finding the belt index where the point looks like:
if(R>r[s-1] && R<=r[s])
{
foundRadius=true;
pos=s;
break;
}
Pre-check that the index s-1 has elements in the r sequence. If not, for example, s = 0, then the previous radius is zero.
The following code can solve this:
/*Specifies the previous radius*/
if(s-1<0) //If it is with the initial index, then the smaller ring of the semicircle is equal to zero
{
rP=0;
}
else{
rP=r[s-1];
}
- radius of concentric circles representing zones and have them n (entered)
- X coordinates of the point within the zone, there are m (entered)
- Y coordinates of the point within the zone, there are m (entered)
Furthermore, using a binary search algorithm, look for a position in a series of radius, where the distance R from the center to the current point M (x, y)
located in a belt that precedes the radius in a row at the examined position.
For example, if the distance from the center of the center R is calculated from the radius in a row at the current position with r [s], then finding the belt index where the point looks like:
if(R>r[s-1] && R<=r[s])
{
foundRadius=true;
pos=s;
break;
}
Pre-check that the index s-1 has elements in the r sequence. If not, for example, s = 0, then the previous radius is zero.
The following code can solve this:
/*Specifies the previous radius*/
if(s-1<0) //If it is with the initial index, then the smaller ring of the semicircle is equal to zero
{
rP=0;
}
else{
rP=r[s-1];
}