# distribute the bounding area into grid space

I have a bounding area of a contour after the slicing operation. Now to generate the tool-path over the contour, I need to distribute the bounding area into grid space so that each each cell maintain a certain precomputed width.

I am doing the math as follows, but I am not sure if the whole area will be covered as there is floating point values concatenated to integer coordinates.

       short int xDist = std::abs(xMax - xMin);
short int yDist = std::abs(yMax - yMin);

short int xCells = (xDist/scanSpacingStep) + 1;
short int yCells = (yDist/scanSpacingStep) + 1;


The indexing starts from (0,0).

Thanks

• Are you doing coding by deferring to stackexhange, perchance? – joojaa May 31 '16 at 12:38
• I totally missed your last question ? – sajis997 May 31 '16 at 12:52
• if xMax and xMin are floats, why is xDist an int? – Rotem May 31 '16 at 14:32
• All the declared variable are in short int . The only floating point issue may arise with xDist/scanSpacingStep. – sajis997 May 31 '16 at 14:47
• I'm not quite sure what you are asking. Are xMax and xMin pixel locations? If so are both inclusive? If xMin=2 and xMax=4, does that cover 2 columns of pixels or 3? – trichoplax Jun 1 '16 at 0:22