I need to create a 375 x 375 grid in c, and I need to create a grid of 25 (5×5) poles that will be spaced 75 (375/5) grid points apart. I will then need to calculate for any given grid point how close it is to a pole. This is not a visual grid, but I’m still having trouble wrapping my head on how to create this grid set-up programmatically. So far, I’v created a “Point” struct that consist of two ints x and y:
typedef struct{
int x, y;
}Point;
I then define my grid as a 375×375 Point array and set the x and y values asi and jrespectfully, in a nested for loop. However I’m having a hard time figuring out how to create the pole position array. Should it be a 5×5 array with the x and y values set as i*15 andj*15? If so then how would I use the two 2D arrays together.I couldn’t do a calculation like this obviously:
for(i = 0; i < 375; i ++){
for(j = 0; j<375; j++){
distance(polePos[i][j], grid[i][j]);
}
}
but If I make it a 375×375 array, then how do I designate the pole position?
Am I on the right track? Any help would be appreciated.
You didn’t specify at which column-/row-indices the poles should be placed so in the following i place them 75-apart starting at 0, so the poles are at column-/row-indices 0, 75, 150, 225, 300, 375 (so 6 poles). It might not be precisely what you had in mind but it will get you started.